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.

Unable to trigger the Subflow from script

Snow Developer4
Mega Contributor

Hi,

 

I'm trying to trigger a subflow from script but getting an error while triggering subflow.

 

even tried from background script but its not working, script which I ran in background is below:

(function() {
  try {

    var result = sn_fd.FlowAPI.getRunner()
      .subflow('sn_ad_spoke.subflow_name') // subflow_name was the flow name which I removed
      .inForeground()
      .run();

    gs.info(result);

  } catch (ex) {
    var message = ex.getMessage();
    gs.error(message);
  }

})();

 

SnowDeveloper4_0-1694546645797.png

 

Can anyone help me out figuring out the issue?

 

Thanks

 

1 REPLY 1

Peter Bodelier
Giga Sage

Hi @Snow Developer4,

 

Generate your script from the flow itself. That way you can be sure it is correct:

 

PeterBodelier_0-1694588572485.png

 

Create code snippet, is what you are looking for.

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.