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.

Run Flow from script

Sylvain12
Tera Contributor

Hi Everyone,

 

I am trying to run a Flow from a background script (final goal is to run it from fix script).

 

However, flow is not triggering, here is the script:

  var inputs = {};
  inputs["table_name"] = "sc_req_item";
  inputs["request_item"] = "RITMXXXXXX"; // here I input RITM number

  sn_fd.FlowAPI.executeFlow("global.the_flow_name", inputs );
}

I also tried with startFlow instead of executeFlow, but result is the same.

 

Am I missing something here ?

 

Thank you very much in advance for your support !

 

Kr,

Sylvain

4 REPLIES 4

Girish12
Kilo Sage

Hi 

 

For the inputs you need to pass GlideRecord Object( gliderecord to ritm table and get the gliderecord object of the RITM)

 

try by removing

 

inputs["request_item"] = "RITMXXXXXX";

 

and pass

 

inputs["current"] = GlideRecord Object

 

 

Hello Girish,

 

Thank you very much for your reply.

 

I tried the above but result is the same:

var grRITM= new GlideRecord("sc_req_item");
grRITM.get("RITM2486673");

  var inputs = {};
  inputs["table_name"] = "sc_req_item";
  inputs["current"] = grRITM.number; 

  sn_fd.FlowAPI.executeFlow("global.demand_management_for_im_products__release", inputs );

 Is this what you meant ?

 

Too late but maybe someone can use it...

var gr = new GlideRecord('task_time_worked');
	gr.get('sys_id');
	try {
		var inputs = {};
		inputs['current'] = gr; // GlideRecord of table:  
		inputs['table_name'] = 'task_time_worked';

 

 

Sohail Khilji
Kilo Patron

Hi @Sylvain12 ,

 

Try this :

 

var grr = new GlideRecord('sc_req_item');
grr.addQuery('number', 'RITMXXXX');
grr.Query();
if(grr.next()){

 var inputs = {};
  inputs["table_name"] = "sc_req_item";
  inputs["request_item"] = grr; 

  sn_fd.FlowAPI.executeFlow("global.the_flow_name", inputs );


}

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect