Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

I need to end the flow ( in flow action ) with completion

Jaiti Mohammed
Tera Contributor

In place of throw I need to end the flow with completion no with error 

JaitiMohammed_0-1762949667074.png

 

2 REPLIES 2

M Iftikhar
Tera Sage

Hello @Jaiti Mohammed,

If you want to end the Action without throwing an error, you don’t need to use throw at all. In a Flow Action Script Step, throwing an error will always send the Flow to the Error path, but using a simple return will end the script and mark the Action as Completed.

 

(function execute(inputs, outputs) {

    var needsRetry = inputs.needs_retry; // Mapped from $(Check for Retry Condition.needs retry)

    if (needsRetry) {
        // Wait 15 seconds only if retry is required
        gs.sleep(15000);
    }
    // No retry needed just complete normally
    return;
})(inputs, outputs);


If you need to send values back to the Flow, you can set output variables before returning.

If my response helped, please mark it as the accepted solution so others can benefit as well.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.

Hi @Jaiti Mohammed,

Did you get a chance to try this? Was it helpful?

If this solution helped, please consider marking it as the Accepted Solution ,it helps others in the community find the answer more easily.

Thanks & Regards,
Muhammad Iftikhar

If my response helped, please mark it as the accepted solution so others can benefit as well.