How to restart a workflow from the scratch?

gowdash
Mega Guru

Hi,

I have a scenario where few RITMs are cancelled without getting approval within the time specified. No tasks were generated so far. Now the requester wants us to open the same RITM again and re initiate the workflow. Is it possible the Restart the workflow from the scratch?

Regards,

Gowdash

4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

Yes it is possible to restart the workflow again.


You can use below code:

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

 

current will be GlideRecord for you RITM.

 

Check: https://community.servicenow.com/community?id=community_question&sys_id=c18ff2e9db58dbc01dcaf3231f9619c2

 

Thanks,
Ashutosh Munot

Harish Kumar3
Mega Guru

Hi,

Use below script in background script, update record sys_id in script:

 

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);
}

Ajaykumar1
Tera Guru

Hi,

Add global as below :

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

Refer to Pradip Sharma's reply in following community thread.

Restart workflow from UI action?

 

Regards,
Ajay

Anita Malhotra
Tera Contributor

Hi,

Yes, you can restart the workflow.
Use this in script:

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

Thanks