Reputation: 189
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 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);
}
}
}
Upvotes: 3
Views: 6411
Reputation: 3287
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 committed 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 committed to the database.
Upvotes: 4