what is the best way to selectNewLine in a user ev...
# suitescript
n
what is the best way to selectNewLine in a user event script? (aka add new lines)
Copy code
tranRec.selectNewLine({sublistId:'item'});
        tranRec.setCurrentSublistValue({sublistId:'item',fieldId:'item',value:item});
        tranRec.setCurrentSublistValue({sublistId:'item',fieldId:'quantity',value:quantity});
        tranRec.commitLine({sublistId:'item'});
i have tried clients side like this ^ (problem: does not seem to commit)
Copy code
tranRec.insertLine({sublistId:'item',line: 0});
        tranRec.setSublistValue({sublistId:'item',fieldId:'item',line: 0, value:item});
        tranRec.setSublistValue({sublistId:'item',fieldId:'quantity',line: 0, value:quantity});
i have tried afterSubmit ^ (problem: line does not get added and there are no error messages)
This is on a sales order record
b
For client side code, you need to use forceSyncSourcing to commit the line after the item is done sourcing
for a before submit user event script, you only need to use setSublistValue on the next available line
you dont need to insert the line unless you actually want to insert a line at the first line
for an after submit user event script, you need to load the record again and save it to make your changes
keep in mind thats its a terrible idea and will double your sales order save times
n
interesting, ok so I will try client side with forcesyncsourcing on
thanks for the write up @battk very helpful