Questions about User Event scripts: I am working ...
# suitescript
s
Questions about User Event scripts: I am working with a customer UE from another account that is being merged into ours. It’s written in SS 1.0, and only runs when type equals ‘edit’ or ‘xedit’ When performing an edit through the UI, there was a call made to get the
'entityid'
value from the NewRecord:
nlapiGetNewRecord().getFieldValue('entityid')
However, about half of the time, the value returned is null. Initially, I thought is was due to xedit (inline edits) since they only contain modified values, but it’s happening in a regular edit as well. Switching the code to use the OldRecord works fine, and essentially fixes the issue. The strange part is that this worked correctly all the time in the old account using the NewRecord, but not in ours, and I can’t figure out what the difference is. Any ideas about what could cause this difference? More generally, I am concerned that any UE could get null values from NewRecord in an edit event, which would likely break a lot of other code we have, though I only see it with this field in this script right now.
netsuite 3
c
Are there any differences in terms of account settings, configurations, or form/field requirements between the two accounts?
s
There are most definitely differences in our account, we are two companies that have a 9 year history with NetSuite (both of us went live in 2014), so many years worth of differences could be present. Having said that, all account features they had enabled that we did not have now been enabled, and all of their customizations merged into our (workflows, scripts, forms, data, etc.) I don’t know where to look, really. entityid is a standard field on customer, and I don’t know how the value could be nullified, or why it only happens half the time. The times when it is returning null do seem to be all triggered by UI edits, though. Scripted edits so far do not show this issue. I figured that might suggest a client script, but could a CS modify what a user event sees in the NewRecord on a beforeSubmit?
c
entityid
is the Name, correct? I'm assuming that in those cases, it's still showing a value in that field after it's saved?
s
yes, it is the customer name field, it never goes blank that i can see, and i have encountered the issues when editing a customer myself (only changing an unrelated custom date field)
it has the same value before, during, and after submit
one big difference in our accounts: we have customer auto-numbering enabled, so entityid is always some unique number, then a space, followed by companyname. the other account did not use that feature, and just required companyname to be unique for every customer. we have a use case for having multiple “copies” of a customer with the same companyname, but with different id prefixes to distinguish them
i have wondered if that causes the issue, however i can’t turn that setting off to test my theory
r
that sounds like madness. good luck
b
fields that dont actually take input are the ones most at risk of not actually being submitted
in the ui, the save process is is triggered by a form post, and fields without inputs may not actually have an input element on the form to be submitted
if you were to edit and save the record via script, you probably wont have the same problem
s
i wonder how it ever worked in old account, unless the customer auto-numbering setting changes the form (removes that field as an input)?
b
was there an actual input element that could be set in the other account?
s
the same field, entityid. We have it labelled as Customer ID on the customer form in both accounts
the only difference being that in the other account, entityid = companyname, but in our account, entityid = entitynumber + ' ' + companyname
Looking more closely, though, there is an Auto checkbox in the old account. if unchecked, that field is editable
it’s not at all editable in our account
b
the question i asked will make very little sense if you dont know what an html input is
s
i am aware
in our account, the field is just a span with class=“input”, but in the old account it’s an actual input tag
so, obviously the setting does make a difference, and directly impacts the ability to use entityid, but only on NewRecord, from the UI, and only if Auto-Generated Numbering is enabled
I never actually suspected that the html form itself controlled what was available in the NewRecord, I just assumed that all fields would be available if visible
strangely, though, custom fields on customer that are set to Inline Text still do have an input tag in the html form, but not the Customer ID / entityid
b
most of the time there is a hidden input element on the page somewhere
sometimes there isnt
s
What’s really interesting here is that the behavior varies by account according to a setting, (in terms of having the hidden input or not) which means that someone could develop code that works in their account, but have it break upon deployment to another account like ours, with this setting enabled. For a while I was at a loss to explain to the admin of the other company why their code worked for years without fail, then suddenly stopped working in ours. At least now I know why, but seems like an unintentional oversight. NetSuite shouldn’t allow scripting to use a field that might be made unavailable in this way, since it returns null even when there is a value present. I’d rather that it gave an error since at least that would warn us against code like this, rather than silently returning a null. The fact that it only did so half the time made it even harder to figure out what was going on, but now I do see that it was consistent, it’s only UI edits that have this issue
e
Did you check the Setup > Auto Generated Numbers in each account? Seems like that's the difference here
s
Yes, that definitely is the difference, but we can’t (or really, don’t want to) turn it off for Customers. Modifying the code was the only viable option for us. The difference in behavior just surprised me.