Hi all,
I have a Before Submit user event script that runs on Item records.
This script updates the defaultreturncost field on the location sublist with the value from the body field cost:
function onBeforeSubmit(event_type) { if(event_type == 'create' || event_type == 'edit' || event_type == 'xedit') { var item = nlapiGetNewRecord(); var cost = item.getFieldValue('cost'); for(var x = 1; x <= item.getLineItemCount('locations'); x++) { item.setLineItemValue('locations', 'defaultreturncost', x, cost); } } } Unfortunately, this does not work when triggered by an inline edit (event_type == xedit).Calling "item.getLineItemCount('locations')" returns -1 instead of the true line item count.I assume this is due to the fact that nlapiGetNewRecord() does not load the record fully and does not have this sublist loaded.What would happen if I loaded the record with nlapiLoadRecord(), performed the changes, and then submitted the item record while inside the Before Submit script?I would think that this shouldn't work since the record is being modified externally before the Before Submit script has completed and so the triggering save should fail with a record changed exception. function onBeforeSubmit(event_type) { if(event_type == 'create' || event_type == 'edit' || event_type == 'xedit') { var item = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); var cost = item.getFieldValue('cost'); for(var x = 1; x <= item.getLineItemCount('locations'); x++) { item.setLineItemValue('locations', 'defaultreturncost', x, cost); } nlapiSubmitRecord(item); } } Any suggestions appreciated - Thanks!