I can call each of these line functions in the con...
# suitescript
s
I can call each of these line functions in the console with the delay caused by entering them manually, and it works beautifully…but if I execute them together, there is no delay in their execution. Has anyone run into this issue recently?
e
What's the issue exactly?
s
@erictgrubaugh previously, these calls would execute serially, so I could enter 1 or ten lines with no issue
now, it seems like they are being executed in parallel..
If you run this on a sales order do you get 10 lines?
My first line doesn’t even commit..
e
19.1?
s
yep
It was happening in 18.2 for inventory detail too
j
You're first line is 0
Hmm.. hold on 1 moment, I may have an answer
s
I don’t get any lines
j
If you take it out of the for loop, does it set one line?
s
It’s like each client function call is now a promise and is returning as soon as it’s called
e
If I use your code exactly, I get one line
s
Right
e
If I set
forceSyncSourcing
on the
item
line, I get 10 lines
s
ahaah!
e
well, not quite, I get 9
but that makes sense
s
yep
That is the issue
e
Yeah they changed the behaviour of the sourcing I believe
It's async now
s
Yep, that makes sense..
c
i think we ran into that randomly w/ another proj @erictgrubaugh w/ the slaving crap?
is that even documented
e
yep
s
It is now
e
I believe there's a section of the release notes about it
s
I think I read about it in the 2019.1 release notes
c
i definitely need to read that then
s
but I didn’t put 2+netsuite together
c
bc why make it easy
s
exactly..what is the case for async without an API to use it?
especially when adding lines? They’re ordered..
ugh
well thanks @erictgrubaugh saved the day!
c
i mean when would you not want this to be sync
s
well, in this case, I want all of the sourcing to complete before I attempt to commit the line.
c
sync not async*
making that stuff async when adding line values doesnt make any sense
e
¯\_(ツ)_/¯
s
At the very least why would they default it to FALSE?
Seems like they just chose the wrong default.
It is in the latest documentation @creece
j
I read the release notes as they were renaming the existing
fireSlavingSync
option to
forceSyncSourcing
(but in a backwards compatible way)
As far as documentation, this behavior was documented way back in SS1 for nlapiSetFieldValue
e
I think the issue is that it seems to not be backwards compatible
s
jkabot, I just updated a 1.0 script and setting ‘synchronous’ to ‘true’ is working, however, I’ve written a bunch of client scripts which didn’t have this value set in the past.. when the default behavior was to synchronously set the field values.. so my complaint is that they changed the default behavior at some point and I wasn’t aware of it.. the awareness part is my fault 😳
@jkabot ^^
j
The options target whether client side setValue et al in wait for dependent fields to source their options. The default has always been, to my knowledge, that they don't wait. E.g. when you set the item field, the rate field needs t source the rate from the item record. The default behavior is that setValue by doesn't wait for that to happen before going to the next line of code. The problem is that setting the item field causes a bunch of fields to source their values, which takes a bit of time. Since setValue doesn't wait by default, those values get sourced after you set them which probably overwrites your values. Additionally trying to call
commitLine
while the item values is still sourcing silently fails. Here I have a script from almost a year ago where I had this same issue. It's not a new behavior in 2019.1
Copy code
rec.selectNewLine({ sublistId: 'item' });
rec.setCurrentSublistValue({
	sublistId: 'item',
	fieldId: 'item',
	value: programItem,
	// must wait for column fields to load for rec.commitLine to work properly
	fireSlavingSync: true
});
rec.commitLine({ sublistId: 'item' });
s
Thanks @jkabot, appreciate your assistance!