What's quicker 1. record.load() then loop through...
# suitescript
c
What's quicker 1. record.load() then loop through every line item to set a value 2. N/search to return a list of lineitems that I need to set the value on? There could be over 1000 lines in the item sublist.
b
your question is missing a choice
you will have to load the record either way if you need to set a value on a line item
c
True, I can't avoid loading the record. The whole script will actually need to load and save the record twice. I guess the only difference is either loop through every item or use a search.
So the real question is, is the loop quicker or the search?
b
usual answer is measure it, but honestly performance optimization usually is minimizing governance
a
• Search • Need to update lines? If YES then LOAD If you know you are going to ALWAYS update some lines, then you know that you always need to load the record. You also need to consider that you can't search on beforeSubmit for a record being created(you don't have an ID yet).
c
So you think a 1000 iteration long for loop is going to be quicker than a search?
a
If you always have to load the record yes.
e
CSV update?