I have a Client Script and trying to add a line it...
# suitescript
m
I have a Client Script and trying to add a line item on saveRecord. Tried: current_record.insertLine > current_record.setCurrentSublistValue > current_record.commitLine current_record.selectNewLine > current_record.setCurrentSublistValue > current_record.commitLine Also tried both without the commitLine. With CommitLine I can see the values getting set before the item line drops as its saving. What I'm I missing? Do I need to load the record first?
m
The saveRecord entry point in client scripts is not a great place to add a new line. That entry point is really for validation.
That said, if I were doing it, I’d use currentRecord.selectNewLine() then use the currentLine APIs to set values and then call currentRecord.commitLine()
👍 1
b
CurrentRecord.setCurrentSublistValue is asynchronous, use forceSyncSourcing to avoid committing before the values are actually set
m
Thanks for the suggestion. The forceSyncSourcing resolved my issue.