how to start or restart a workflow context without passing stages by default in servicenow?

anjalikulkarni
Kilo Contributor

We have a requirement where I want to restart the workflow that is already finished. We have used the script mentioned below   to restart the cancelled workflow but after restarting, the workflow is passing the stages by default.

var wkfw = new Workflow();

//var cancelflow = wkfw.getWorkflowVersionFromName('Workflow name');

var wfgr = new GlideRecord("wf_workflow");

wfgr.addQuery("name","'Workflow name");

wfgr.query();

if(wfgr.next()){

var wfid = wfgr.sys_id;

var x = new WorkflowApprovalUtils().reset(current, "res");

var context = new Workflow().startFlow(wfid, current, current.operation());

}

To restart the workflow, we have referred to the link below Restart a workflow context without affecting other workflows running on the record

Can anyone please guide on the same?

9 REPLIES 9

I love this community!


Hi Khushboo,



Workflow is starting with new context, but bydefault it is passing all states/approvals. How to restart/reset all approval activities before restarting of the workflow context?



Thanks,


Anjali


rajagowthamredd
Kilo Explorer

Have you got the solution for this??, if yes could you please provide us as we  the similar requirement where we need to restart only one workflow out of 2 workflows

Hi, 

 

Have you tried the below one?


new Workflow().startFlow(wflw.getWorkflowFromName('name of the workflow'), current, 'update');
 
If it works, please let me know
 
 
Thanks,
K