Cancelling a Service Catalog Request After Period of Time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 12:39 PM
We currently have a Service Catalog process where people can request some services. We have been asked that any request that is sitting in the "Pending Approval" Stage for more than 60 days should be automatically cancelled, and an email should be automatically sent to the requestor letting them now.
What is the best way of doing this? I am thinking making changes to the Workflow, but not sure on the specifics of it. Maybe something like starting a timer once the approval is requesting, then adding a Wait For condition that after 60 days cancels the request and emails the user? Obviously, I would also need to stop the timer once it moves out of the "Pending Approval" stage.
Do I have the steps correct? Is that the best way go about it?
Thanks
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 12:50 PM
What you might want to consider is using a Scheduled Job to query the approvals against Requests and if the approval is over x number of days, cancel the Request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 12:54 PM
In my searches, this thread seemed to suggest that they may not be the best idea (if I am understanding it correctly): Auto Reject an approval after 14 days
However, I didn't see anything in that thread mentioning Workflows, so was trying to determine:
- if it was a good idea to do it in the workflow
- exactly what that should look like

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 02:04 PM
I've done something similar.
Basically, you are looking to update the approval record (reject it with comments that time had expired) and let the normal workflow handle the rejection just like it would if the user initially rejected.
Mine was an approval reminder setup that queried the approvals for catalog items and gave approval reminders twice a few days apart with the last one a warning to act or it would automatically be rejected.
If you can create a filter on the approval table to find those approvals that have been created more than 14 days ago, you can then use that query in your scheduled job and just set those to rejected with some comment and the workflow will handle the rest.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2017 02:15 PM
Here is the rejection part of my scheduled job. I just run this early in the morning each day.
var gr = new GlideRecord('sysapproval_approver');
var querystring = "state=requested^sysapproval.sys_class_name=sc_req_item^sys_updated_onRELATIVELT@dayofweek@ago@14";
gr.addEncodedQuery(querystring);
gr.query();
while (gr.next()) {
gr.state = 'rejected';
gr.comments = "Automatically rejected after 16 or more days of inactivity";
gr.update();
}