Thursday, October 11, 2018

Return a Value from a Workflow Action Script

 

Sublists are not yet supported as of this time. In cases where there is a need to retrieve a value from a field in the sublist, Workflow Action Script is generally employed. This demonstrates how to return a value from the Workflow Action Script to the Workflow.

Workflow Action Script:
1. Create a Workflow Action Script
function LineItem()
{
var rec = nlapiGetNewRecord();
var lines = rec.getLineItemCount('item');

for (var i = 1 ; i<= lines ; i++ ) {
qty = rec.getLineItemValue('item', 'quantity', i);
if (qty==0){
return "0";
}
}
return "1";
}


2. Make sure that the script returns a value

Workflow Settings:

3. Create a custom workflow field. Note that it should be the of the same type as the return parameter of the workflow action script

4. Call the custom Action (Workflow Action Script). Note the the return value from the workflow action script can be stored in the field "Store Result In"

No comments:

Post a Comment