I've created a workflow that has a workflow action script to create a new record using mass update.
This is working but now I need to pass values from custom workflow fields set in the mass update screen into the script so I use them to set values on the new record and I just can't figure it out.
Any help would be greatly appreciated.
Thanks
If you have created a custom mass update script you would have created parameters accessed like :
runtime.getCurrentScript().getParameter({name:'custscript....'});
If so and you are then triggering the work flow via:
workflow.initiate({
recordType:'customer', ...
then you might do something like:
/**
* @NApiVersion 2.x
* @NScriptType MassUpdateScript
*/
define(["N/runtime", "N/workflow"], function (runtime, workflow) {
function each(params) {
workflow.initiate({
workflowId:'customworkflow_target_id'
recordType: params.type,
recordId: params.id
defaultValues:{
custworkflow_field_1:runtime.getCurrentScript().getParameter({name:'custscript_field_1'})
// and so on. of course you'll probably dereference runtime.getCurrentScript() if you have multiple parameters
// You'll have to define workflow fields for every value you want to pass.
// custscript_field_1 is from the id of the workflow fields.
// For sanity's sake I recommend giving your script parameters similar ids as the workflow field ids
}
});
}
exports.each = each;
});