Why is my workflow action script taking so long to run?

I found a script that was being used to change a Sales Order status and decided to try and use it for a return authorization approval workflow. The script does successfully change the status from Pending Approval to Pending Receipt after at least a minute of “thinking”. When I check the execution log it shows the funcName “Starting” happening 15 times before returning the “approved”. I am using saved searches to transition the ones I want cancelled to other states and if the RMA is not caught on any of those it moves to the approved state where this script happens. Any pointers?

* @NApiVersion 2.x
* @NScriptType workflowactionscript

function(record) {
var scriptName = “RTN_Approved “;
“use strict”;

function onAction(context) {
var funcName = scriptName + “onAction ” + context.newRecord.type + ” ” + context.newRecord.id;

log.debug(funcName, “Starting”);

try {
var RTN = record.load({type: context.newRecord.type, id: context.newRecord.id});

fieldId: ‘orderstatus’,
value: ‘B’});
log.debug(funcName, “approved”);

} catch (e) {
log.error(funcName + “Unable to approve error”, e)

return {
onAction : onAction


Rookie Asked on March 9, 2021 in SuiteScript.
Add Comment
3 Answer(s)

I figured it out. My transaction was leaving and entering the workflow by the time it was making the changes so once I made it so the transaction did not exit the script did exactly what I wanted.

Rookie Answered on March 16, 2021.
Add Comment

Test this script without workflow, if taking same time then go in detail of script.

Rookie Answered on March 16, 2021.
Add Comment


Rookie Answered on March 16, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Become a Sponsor   Become a Sponsor