Flow is getting failed to give output when executed via script .the flow has some for loop to check

CharanKulukuri
Tera Contributor

Hi all,

I’m trying to call a subflow from a Script Include (triggered via GlideAjax from a Catalog Client Script) and return the output to populate a select box dynamically on a catalog item whle submiting.

Current flow:

  • User selects a subnet on the Service Portal catalog item
  • onChange Client Script calls Script Include via GlideAjax
  • Script Include calls subflow using:
sn_fd.FlowAPI.getRunner()
    .subflow('global.subnet_ranges')
    .inForeground()
    .withInputs(inputs)
    .timeout(300000)
    .run();
  • Then tries to get outputs:
var outputs = result.getOutputs();
var subnet_ranges = outputs.subnet_ranges;

Problem:
I get the error:

The current execution is in the waiting state

If I increase timeout, I instead hit:

An execution timed out with timeout of 30000 MILLISECONDS

Observation:
The subflow includes steps like:

  • Launch Job Template (Ansible)
  • Possibly waits for completion / external processing and pass outpus

So it does not complete immediately.

What I’m trying to achieve:

  • Fetch subnet ranges dynamically based on selected subnet field on portal of a catalog item 
  • get the outputs from subflow and add them as option and Populate a dropdown field (subnet_ranges) on the catalog item before submission

Questions:

  1. Is it expected thatinForegeround() fails if the subflow contains wait/async steps?
  2. Is there any supported way to synchronously return outputs from such a subflow?
  3. If not, what is the recommended pattern for this use case (catalog client script → dynamic dropdown)?
  4. Is using inBackground()+ storing results in a custom table + polling via GlideAjax the correct approach?

Would appreciate guidance or best practices for this pattern.

Thanks!

0 REPLIES 0