Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
Now is the time to ask your NetSuite-savvy friends and colleagues to join the NetSuite Support Community! Refer now! Click here to watch and learn more!
ClientScript : saveRecord : commitLine not working on a Journal Entry
Hello,
I have a simple piece of SS2.0 code that is designed to check a few conditions and insert two lines into a Journal Entry on save of the record via client scripting. The curious thing is even though I am using commitLine, the lines I am trying to add to the JE never actually insert and instead overwrite one another into the first sublist line. Is this a SS2.0 bug or am I missing something?
var recObj = scriptContext.currentRecord; var rulesObj.lines = [{ "sublist": "line", "account": "51010000 PURCHASES-RED", "acctid": "295", "entry": "debit" }, { "sublist": "line", "account": "11020000 CCCC-A/C #619727799", "acctid": "417", "entry": "credit" }]; util.each(rulesObj.lines, function(field){ var lineNumber = recObj.findSublistLineWithValue({ sublistId: field.sublist, fieldId: 'account', value: field.acctid }); if(lineNumber==-1){ recObj.selectNewLine({ sublistId: field.sublist }); }else{ recObj.selectLine({ sublistId: field.sublist, line: lineNumber }); } recObj.setCurrentSublistValue({ sublistId: field.sublist, fieldId: 'account', value: field.acctid }); recObj.setCurrentSublistValue({ sublistId: field.sublist, fieldId: field.entry, // either debit or credit based on object value: somecost.toFixed(2) }); recObj.commitLine({ sublistId: field.sublist }); }); 0