最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SuiteScript: before Submit (Set sublist Value using user event script) - Stack Overflow

programmeradmin1浏览0评论

I'm able to get values but not able to set sublist values in user event script beforeRecord submit. Looping through every line item to get the satisfying condition, when it e's to set value, I couldn't. am I passing wrong value or something? I'm not even receiving errors.

Please view script (edit):

if (context.type == context.UserEventType.EDIT) { var salesOrderRecord = context.oldRecord; var formId = salesOrderRecord.getValue({ fieldId: 'customform' }); if (formId == 150 ) { var recordId = salesOrderRecord.id; var lineCount = salesOrderRecord.getLineCount({ sublistId: 'item' }); for(var i = 0;i < lineCount; i++){ var sublistItemId = salesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); if (sublistItemId != '' && sublistItemId == 29498) { log.debug('Get Values',sublistItemId); salesOrderRecord.setSublistValue('item','location',i,39); } } }

I'm able to get values but not able to set sublist values in user event script beforeRecord submit. Looping through every line item to get the satisfying condition, when it e's to set value, I couldn't. am I passing wrong value or something? I'm not even receiving errors.

Please view script (edit):

if (context.type == context.UserEventType.EDIT) { var salesOrderRecord = context.oldRecord; var formId = salesOrderRecord.getValue({ fieldId: 'customform' }); if (formId == 150 ) { var recordId = salesOrderRecord.id; var lineCount = salesOrderRecord.getLineCount({ sublistId: 'item' }); for(var i = 0;i < lineCount; i++){ var sublistItemId = salesOrderRecord.getSublistValue({ sublistId: 'item', fieldId: 'item', line: i }); if (sublistItemId != '' && sublistItemId == 29498) { log.debug('Get Values',sublistItemId); salesOrderRecord.setSublistValue('item','location',i,39); } } }

Share Improve this question asked Feb 6, 2018 at 3:08 HarishHarish 1892 silver badges13 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

In a before submit function, context.oldRecord is a reference to the sales order before it was edited by the user. context.newRecord is a reference to the sales order after it was edited by the user but before it is mitted to the database.

If you need to make changes, you should be updating context.newRecord as this will also include the changes to the record that the user just made and is the record that is going to be mitted to the database.

发布评论

评论列表(0)

  1. 暂无评论