Subflow having wait for duration flow logic failing when called from script

saikrishna_12
Tera Guru

Issue:
we have a subflow which having "wait for duration of time" flow logic, when we calling that subflow from serverside with code snippet it showing error in catch block like below, how to call such subflows with script having such waits... !?

Error:
com.glide.plan.runners.FlowObjectAPIException: The current execution is in the waiting state

Code:
try {
        var result = sn_fd.FlowAPI.getRunner().subflow('global.test').inForeground().run();
        var outputs = result.getOutputs();
        var output = outputs['output']; // String
        gs.info(output)
    } catch (ex) {
        gs.info('error123 '+ex);
    }

 

wait for duration is only 15sec ...

2 REPLIES 2

Sonam Tiwari
Tera Guru

Hi @saikrishna_12 ,

Please refer to the solution of this thread which should give you a clarity on why this is happening,

https://www.servicenow.com/community/developer-forum/subflow-does-not-return-outputs-to-script-inclu...

Thanks,

Sonam

SA27
Tera Contributor

Try setting a timeout sn_fd.FlowAPI.getRunner() .flow('global.test_flow') .inForeground() .timeout(1500) .run();