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.

Launching Service Catalog Triggered Flow via Workflow Script

Chris Schuh
Giga Contributor

Hi Everyone,

I am currently trying to launch a flow via a script in a Workflow. I have used the code snippets and the examples found here, but for some reason the flow just won't start.

https://developer.servicenow.com/app.do#!/api_doc?v=london&id=FlowScoped-startAsync_S_GR

Here's an example of the code:

(function() {

try {

var glideRecordInput = new GlideRecord('sc_req_item');
glideRecordInput.get(current.sys_id);

var inputs = {};
inputs['request_item'] = glideRecordInput; // GlideRecord of table: sc_req_item
inputs['table_name'] = glideRecordInput.getTableName();

// Start Asynchronously: Uncomment to run in background.
sn_fd.FlowAPI.startFlow('global.flow_name', inputs);

// Execute Synchronously: Run in foreground.
//sn_fd.FlowAPI.executeFlow('global.flow_name', inputs);

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

})();

 

 

I have the above code wrapped in an if statement, as I want to only trigger the flow to run in certain conditions. Any help would be greatly appreciated.

10 REPLIES 10

I do have the correct flow name in the call, but I did edit it for the community as it's for a client.