RE: 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 + ” ” +;

log.debug(funcName, “Starting”);

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

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

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

return {
onAction : onAction


bsarsg Rookie Asked on March 9, 2021 in SuiteScript.
Add Comment
3 Answers

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

Rookie Answered on March 16, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.