- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:05 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 01:24 PM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:08 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:33 AM
Since the approval is already canceled should i be just using restartworkflow ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2017 10:54 AM
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.