Rerun Flow

athavichith
Mega Sage

How do I rerun a flow that failed or did not generate a task after I had made a modification to the flow?

1 ACCEPTED SOLUTION

@athavichith 

you can use this to re-run the flow for your RITM

FlowAPI - Scoped, Global 

FlowAPI - Scoped, Global 

var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("number=RITM0001"); // provide a Query
grScReqItem.query();
if (grScReqItem.next()) {
    try {
        var inputs = {};
        inputs['request_item'] = grScReqItem; // GlideRecord of table: sc_req_item
        inputs['table_name'] = 'sc_req_item';
        var contextId = sn_fd.FlowAPI.startFlow('your Flow name', inputs);

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

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@athavichith 

you can use this to re-run the flow for your RITM

FlowAPI - Scoped, Global 

FlowAPI - Scoped, Global 

var grScReqItem = new GlideRecord('sc_req_item');
grScReqItem.addEncodedQuery("number=RITM0001"); // provide a Query
grScReqItem.query();
if (grScReqItem.next()) {
    try {
        var inputs = {};
        inputs['request_item'] = grScReqItem; // GlideRecord of table: sc_req_item
        inputs['table_name'] = 'sc_req_item';
        var contextId = sn_fd.FlowAPI.startFlow('your Flow name', inputs);

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

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @athavichith The new changes in the flow will apply only to new records, and there's no need to run the new flow on old records. It's possible that you added a new variable or condition that doesn't match with the old records.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************