Reputation: 5
I was tasked to set a workflow action script that sets a field value upon CSV Import but I was given an error of "Cannot call method setValue of undefined". What are the common symptoms for this and how should I deal with it? Here is my code
* @NApiVersion 2.x
* @NScriptType WorkflowActionScript
* @NModuleScope public
*/
define(['N/record'], function (r) {
r.Record.setValue({
type: r.Type.PURCHASEORDER,
fieldId: 'memo',
value: 'CSV Field script',
ignoreFieldChange: true,
});
return{
onCreate:
}
});
Upvotes: 0
Views: 1862
Reputation: 28
Workflow scripts have a single entry point of onAction
. Also, I don't understand why you would use a workflow script to set a field value when that is already an available workflow action option.
If for some crazy reason you have to do this, I would use your workflow action to pull the ID of the record and then pass that value to a separate function. The function would be something like:
function setMemo(recordId){
record.submitFields({
type: record.Type.SALES_ORDER,
id: recordId,
values: {
'memo': 'CSV Field Script'
}
})
}
Upvotes: 1