Triggering a flow with inputs from a script?

Ivar Donado
Mega Sage

Hi guys,

I’m currently working on enhancing a Flow I created a while ago. What I need to do is to be able to trigger it and set some parameters while I’m on it. I know SN provides the following methods:

  • executeFlow(flow name, inputs)

  • startFlow(flow name, inputs)

They seem to allow passing inputs as parameter, however I don’t see a way to configure or retrieve them in the Flow.

The context is: This flow will run all the ATF test suites, gather the results and send that info to the stakeholders. I created it and it works, however now we need to run two sets of suits: One for Chrome and one for Firefox to make sure all the client side stuff works correctly in those browsers. I wanted to re-use the flow by triggering it from a scheduled job and passing a parameter with the browser.

 

PS: While writing this question I realized that I might be able to save this flow as a subflow and trigger it from the script while passing the inputs as parameters. I’ll check if there are no repercutions to this.

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

executeFlow and startFlow are actually old deperecated methods. You could use:

Async:

var inputs = {
	'sysid' : '9d385017c611228701d22104cc95c371'
};

var result = sn_fd.FlowAPI
		  .getRunner()
		  .subflow(inputs)
		  .inBackground()
		  .withInputs(inputs)
		  .run();

Sync:

var inputs = {
	'sysid' : '9d385017c611228701d22104cc95c371'
};

var result = sn_fd.FlowAPI
	          .getRunner()
		  .subflow(inputs)
		  .inForeground()
		  .withInputs(inputs)
		  .run();

In this example I'm only providing a sys_id as input and expecting the subflow to contain a input "sysid".

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Can you tell me how should I configure the flow for this? I want the flow to be triggered when its called by the flow API in my widget and I want to pass the user email from widget to my flow. What trigger should I add?