Re-submit multiple ritms

mipalm
Tera Guru

Hi,

I have developed a flow where multiple RITMs failed on the last step.

We have since fixed this issue with the flow, however the Requests are still there, is there any way to re-submit these requests in bulk without doing it manually in the 'test flow' feature?

Even better if we can run the flow only from a certain step, so the RITM dont have to go throug approval again.

 

Thanks 

1 REPLY 1

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @mipalm ,

 

Your scenario is complex, there can be multiple RITM from diffrent catalog and diffrent state of workflow... I belive it will be hard to categories RITM and rerun from certain states (will be time consuming and will required individual item action). I have this script below which cancels exsiting ritms and resubmits them in to a new request.

 

FYI :

//reopen REQ
current.state = 1;

//reopen RITM
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.addQuery('state', 'IN', 3,4,7);
ritm.query();
if (ritm.next()) {
	ritm.state = 1;
	ritm.update();
	current.update();
	action.setRedirectURL(current);
	gs.addInfoMessage('REQ and RITM ' + ritm.number + ' reopened.');
	
	//restart workflow on RITM
	var wflow = new Workflow();
    wflow.restartWorkflow(ritm);
    wflow.runFlows(ritm, "update"); // the update is just going to nudge the workflow
}
//mark all existing approvals for the change as 'cancelled' and restart the workflow to create new approvals 
//where current is a task record with a workflow context 
new WorkflowApprovalUtils().cancelAll(current, comment); 
new Workflow().restartWorkflow(current);

var ritm = new GlideRecord("sc_req_item");
if(ritm.get("<sys_id of RITM>")){
new WorkflowApprovalUtils().cancelAll(ritm , "<comment if any>");
new Workflow().restartWorkflow(ritm);
}

new Workflow().restartWorkflow(current, true);

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

LinkedIn - Lets Connect