How to retrigger flow for RITM

KartikM49574975
Kilo Sage

Hello All

I have approximately 100 Requested Items (RITMs), and I've made modifications to an existing Flow. Is there a way to retrigger the existing Flow for those 100 records?

 

Any assistance in resolving the issue would be greatly appreciated. 

Thanks and Regards

Kartik Magadum

4 REPLIES 4

Sumanth16
Mega Patron

HI @KartikM49574975 ,

 

(function() { 


var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("Query");// provide a Query
grScReqItem.orderBy('sys_created_on');
grScReqItem.setLimit(1);
grScReqItem.query();
while (grScReqItem.next()) {
try {
	
	var flow = grScReqItem.cat_item.flow_designer_flow;
	var flowName = flow.sys_scope.scope + "." + flow.internal_name;
    var inputs = {};
    inputs['request_item'] = grScReqItem; // GlideRecord of table: sc_req_item
    inputs['table_name'] = 'sc_req_item';

    var contextId = sn_fd.FlowAPI.startFlow(flowName, inputs);	
	
  } catch (ex) {
    var message = ex.getMessage();
    gs.error(message);  
  }
}
})();

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda

 

Thanks for your response. 

Could you please provide step by step guidance. 

Amit Gujarathi
Giga Sage

HI @KartikM49574975 ,
I trust you are doing great.
Pease find the code for the same:

// Replace 'your_flow_api_name' with the actual API name of your Flow
var flowApiName = 'your_flow_api_name';
// Replace 'your_query' with a query that matches the 100 RITMs you want to target
var ritmQuery = 'your_query';

var ritmGR = new GlideRecord('sc_req_item');
ritmGR.addEncodedQuery(ritmQuery);
ritmGR.query();
while (ritmGR.next()) {
    // Trigger the Flow for each RITM
    sn_fd.FlowAPI.startFlow(flowApiName, null, null, { 'record': ritmGR });
}

Thanks for your response. 

Could you please provide step by step guidance..