[英]SuiteScript: before Submit (Set sublist Value using user event script)
I'm able to get values but not able to set sublist values in user event script beforeRecord submit. 我可以获取值,但不能在用户事件脚本中设置beforelist提交之前的子列表值。 Looping through every line item to get the satisfying condition, when it come'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); } } }
In a before submit function, context.oldRecord
is a reference to the sales order before it was edited by the user. 在之前提交功能中, context.oldRecord
是对用户修改销售订单之前的引用。 context.newRecord
is a reference to the sales order after it was edited by the user but before it is committed to the database. context.newRecord
是销售订单的参考它是由用户编辑之后 ,但在它被提交到数据库。
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 committed to the database. 如果需要进行更改,则应该更新context.newRecord
因为这还将包括对用户刚刚进行的记录的更改,该更改是将要提交给数据库的记录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.