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-11-2017 08:11 AM
Looks promising Steve. I will play around with it, and post back (might not get to it until early next week).
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2017 08:34 AM
So, they actually really want us to do it in the Workflow. It turns out that it wasn't that hard to do in the Workflow.
We simply added a new Timer after our IF action that asks whether or not the Request requires approval (if Yes, create this new Timer). Once the timer hits 60 days, it will send out a Notification that it has been rejected, then I send it to the existing part of the Workflow that rejects everything (the same place the "Rejected" option of the "Approval - User" action goes to.
I just then added another "Run Script" action after my approval action that will stop the Timer. The code for that looks something like this:
//Query executing workflows
var activity = new GlideRecord('wf_executing');
//Find the one running against the current record that was just approved
activity.addQuery('context.id', current.sys_id);
//Activity is the short description, so call your timer Telecom Timer or change the name below to whatever you want
activity.addEncodedQuery('activityLIKETelecom Auto Reject Timer');
activity.query();
//If it finds a timer activity, cancel it.
while(activity.next()){
//just writing to the log for troubleshooting, can remove if you'd like.
gs.log("**************Cancel timer found: " + activity.sys_id);
//cancel the time activity
activity.state = 'cancelled';
activity.update();
}
So that seems to work well, and handle everything right in the Workflow.