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 one time for all records

Giri6
Tera Expert

I have the following flow. I want to trigger the first time for all records from the table.  Appreciate how it can be done. I guess I have to do fake update on each record or not sure if a temporary trigger condition can be changed to execute for all of the records.

 

Giri6_0-1701434823230.png

 

2 REPLIES 2

Kavita_Bhojane
Tera Guru

Hi @Giri6 ,

 

Why would you like to run the flow?

 

Regards,

Kavita Bhojane

 

 

Peter Bodelier
Giga Sage

Hi @Giri6 

 

2 ways to do it.

 

- Copy the flow and lookup all current records first, do a for each loop in the flow.

- Copy the code snippet from flow designer, and use that in a fix script in a loop where you query all records.

 

Something like 

var ci = new GlideRecord('cmdb_ci_computer');
ci.query();
while (ci.next()){
	try {
		var inputs = {};
		inputs['current'] = ci; // GlideRecord of table:  
		inputs['changed_fields'] = []; // Array.Object 
		inputs['table_name'] = 'cmdb_ci_computer';

sn_fd.FlowAPI.getRunner().flow('<<FLOWNAME>>').inBackground().withInputs(inputs).run();
				
	
	} catch (ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
}

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