There could be multiple items in an SO with the sa...
# suitescript
a
There could be multiple items in an SO with the same item instead of doing a qty, so I wanted the explicit line, which I have however it does not directly seem to corrolate with any way to load that line lol
j
the
line
parameter in API calls that interact with sublists refers to the position of the item, and not to any field there just happens to also be a (to my knowledge) mostly undocumented field called
line
that netsuite uses internally
c
i think you mean linesequence and line
(respectively)
j
i mean when you do record.getSublistValue({ sublistId: 'item', fieldId: 'item', line: 1 }), the
line
parameter refers to the position of the item and not to a field
a
I guess my frustration point is lack of naming consistency and implementation. Line references a uniqueid however loading by line is asking for its respective position. That doesnt seem logical
c
line is a unique ID not the position. You can have lines 1,2,3 and then delete 3 and add a new line and that "new" 3 has a line of "4"
a
I understand, I guess all I'm asking is now I have that ID how do I use it to load the line lol
I can't seem any way to load the sl item with it
I can't not seem to directly identify which fieldId stores that value to load by it
j
What I ended up doing is make my own column field to serve as a unique ID. I was frustrated at the lack of documentation / access to whatever fields netsuite uses internally.
I generate a unique value for each item on beforeSubmit
a
I remember you mentioning that before and I may have to do that but I just hate reinventong the wheel it has to be here somewhere
Funny enough if you load a line using findSublistLineWithValue and the field item, then getCurrentSublistValue for line it returns the correct result. However if you attempt to findSublistLineWithValue using the field 'line' you get a -1 result.
j
I wonder if it has something to do with whether findSublistLineWithValue uses strict equality or not try passing a string instead of a number or vice versa
a
I passed it as a string, according to the records browser the line column is a text field, I can try parsing it as an integer though
j
I just tested using the browser console, so at least in a client script findSublistLineWithValue worked with the
line
field
Copy code
rec.findSublistLineWithValue({ sublistId: 'item', fieldId: 'line', value: '1' }) // output: 0
a
var lineTest = soRecord.findSublistLineWithValue({ sublistId: 'item', fieldId: 'line', value: lineid });
UE doesnt seem to work, and I verified the value of lineid was 3
result is -1
I did try with parseInt(lineid) just for giggles too
j
does getSublistValue({ sublistId: 'item', fieldId: 'line', line: idx }) return 3 for any idx?
a
its just not consistent behavior between UE and CS
I did this but yea: var lineNumber = soRecord.findSublistLineWithValue({ sublistId: 'item', fieldId: 'item', value: item }); var lineNum = soRecord.selectLine({ sublistId: 'item', line: lineNumber }); var wrxLine = soRecord.getCurrentSublistValue({ sublistId: 'item', fieldId: 'line' });
wrxLine returns the correct result of 3
Which I then now have to do this: if(lineid == wrxLine){
Of course it wont work if there is more than one items of the same thing on a so
bleh
Sorry I don't know how to format the code in slack lol
j
that's quite frustrating netsuite
you use backticks `
triple backticks above and below for blocks of code
a
Copy code
if(lineid == wrxLine){
Brilliant, thanks lol. At least something works 😛
j
but it sounds like if calls to getXXXvalue work for the
line
field you could roll your own findSublistLineWithValue that "works correctly"
a
I was thinking that, but another sublist loop sounds like a heavy hit on performance...
I wonder how much of their API is looping half the time
j
i'm sure findSublistLineWithValue is already a loop
a
Very true lol
Good plan I'll go whip that up in a lib
thanks!
j
but honestly in my experience in-memory code execution is never the source of performance latency
it's always database i/o like searches or record loading
or http calls
a
With NS for sure. The lag can be pretty brutal at times
j
the in-memory sublist is pretty much an array that netsuite hides behind a byzantine API
a
I would hate to be a guy that works AT Netsuite as an engineer 😕
j
i'm not sure if there's any overhead using "dynamic mode" calls like selectLine
but i wouldn't sweat looping and reading values
yeah lol
c
dynamic mode can add slight overhead but its not gonna matter for such small datasets
j
if we are seeing the customer-facing side (which you'd normally want to be at least a little consistent) who knows what things are like internally
c
I just imagine a lot of shitty java code
a
Thanks for the help guys, I have this fixed now with my own lookup function. What a pita. I have never seen a variable name overlap so poorly in such an expensive application before 😕
c
all good glad you got it working