Reopen cancelled request

rev3
Mega Expert

How to reopen cancelled Request.

I am changing request state and stage and setting the workflow to true using the below script:

var gr= new GlideRecord('sc_request')

gr.addQuery('sys_id', 'sample sys_id');

gr.query();

while(gr.next()) {

gr.request_state="pending";

gr.setWorkflow(true);

gr.update();

}

But the workflow is not setting back. Is there a way to run the workflow again.

Thank You

1 ACCEPTED SOLUTION

Rather than gr.sys_id, it expects the GlideRecord object.



var gr= new GlideRecord('sc_request')


gr.addQuery('sys_id', 'sample sys_id');


gr.query();


while(gr.next()) {


        gr.request_state="pending";


  new WorkflowApprovalUtils().cancelAll(gr, "comment");


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


        gr.update();



}


View solution in original post

10 REPLIES 10

Chuck Tomasi
Tera Patron

You will need to restart the worfklow with something like like this:



new WorkflowApprovalUtils().cancelAll(current, comment);
new Workflow().restartWorkflow(current);



https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=r_Workflow_Workflow


Since the approval is already canceled should i be just using restartworkflow ?


var gr= new GlideRecord('sc_request')


gr.addQuery('sys_id', 'sample sys_id');


gr.query();


while(gr.next()) {


gr.request_state="pending";


new WorkflowApprovalUtils().cancelAll(gr.sys_id, "comment");


new Workflow().restartWorkflow(gr.sys_id);


gr.update();



}



I added that but still the workflow is not setting. I tried to change the state of the approval to requested biut still cannot reset it back.