
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 01:29 AM
Hi Team ,
We have two catalog item as below
1. to add access when the start time is met and to revoke access when the end time is met
2 User can submit another request to revoke the access well.
I need to move the first catalog item workflow end activity if the user submits the second catalog item request.
I am able to update the workflow context and able to cancel the workflow as well but the workflow is not moving to end activity.
Any inputs on this would be much appreciated !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 04:38 AM
Hi,
try to cancel the workflow using script then
var workflow = new Workflow();
workflow.cancel(grReqItem);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 12:25 AM
Hi,
So the logic I shared is working fine.
You can update the stage as well in the same script
regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 02:02 AM
I couldn't find your script but the below one is closing REQ and RITM but the workflow is still showing as executing state
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('sys_id',<RITM ID>);
grReqItem.query();
if (grReqItem.next()) {
grReqItem.work_notes = "Your ReadOnly Admin access has been revoked";
grReqItem.setWorkflow(false);
grReqItem.active = false;
grReqItem.state = 3;
grReqItem.stage = 'complete';
grReqItem.update();
var grRequest = new GlideRecord('sc_request');
if (grRequest.get(grReqItem.request)) {
grRequest.setWorkflow(false);
grRequest.active = false;
grRequest.state = 3;
grRequest.request_state='closed_complete';
grRequest.stage = 'complete';
grRequest.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 02:11 AM
Hi,
don't use setWorkflow(false)
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 02:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 04:38 AM
Hi,
try to cancel the workflow using script then
var workflow = new Workflow();
workflow.cancel(grReqItem);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader