I need to add lines to a sublist on another record...
# suitescript
n
I need to add lines to a sublist on another record based on teh current record I just saved
m
What kind of script is this?
n
Well, I was thinking I have to do a client script in order to do a newlineselect and then commit in case there are already items in the list.
But thinking now maybe I could use a UE after submit, get the id, and then get the number of items in the sublist of another record and use that on the setsublistvalue maybe?
m
There you go!
😀
👍 1
n
@mayerlench the only problem I am seeing now is I can do a new line in a UserEvent script
m
Theres two ways to go about it
If you know the number of lines in the sublist you can add a new line at the end
Or you can load the record in dynamic mode. This mimics the UI and you can use the rec.selectNewLine function in the api
n
How do I add new line if I know the number and SelectNewLine only works on CS not on UE which is what I need to use
b
use N/record module to load the record
the record loaded by N/record has the methods you need
n
I am loading the record but how do I add a new line to sublist in a UserEvent script?
m
If you use the record.getLineCount function. This will return you the sublist count. You can then call the record.setSublistValue passing it the sublistCount as the line value
Or as battk suggested you can load the record with the option
isDynamic: true
then you can use the selectNewLine
b
you probably want to review the different ways of adding sublist lines
the examples are in ss1, but the concept is the same in ss2
n
Okay, I tried and got this error @battk @mayerlench
Cannot find function setSublistValue in object dynamic record.
m
When in dynamicMode you need to use setCurrentSublistValue
n
After setting with that do I have to save the record?
Got it working. Thanks @battk @mayerlench
305 Views