I am attempting to set defaults for the sales team. I have multi-location inventory activated and would like to default the Reorder Points via a Workflow Action Script. The Workflow is successfully setting values for a few other fields already.
/**
* @NApiVersion 2.x
* @NScriptType WorkflowActionScript
*/
define([], function() {
function onAction(scriptContext){
log.debug({
title: 'Start Script'
});
var objRecord = scriptContext.newRecord;
objRecord.setCurrentSublistValue({
sublistId: 'locations',
fieldId: 'reorderpoint',
line: 3,
value: 0
});
}
return {
onAction: onAction
}
});
I'm very new to this and have tried several different trigger points. When I set it to trigger on save, I receive: You have attempted an invalid sublist or line item operation. You are either trying to access a field on a non-existent line or you are trying to add or remove lines from a static sublist.
Any help is appreciated.
Not 100% on the field IDs but found another script referencing those.
There are a few issues with your script:
var lineNum = objRecord.selectLine({
sublistId: 'item',
line: 3
});
objRecord.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'item',
value: 123,
ignoreFieldChange: true
});
See https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4273171484.html