How to retrigger flow for RITM

Kartik Magadum
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
Kilo Patron

HI @Kartik Magadum ,

 

(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
Giga Sage

HI @Kartik Magadum ,
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 });
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Thanks for your response. 

Could you please provide step by step guidance..