Auto Reject an approval after 14 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2014 05:00 AM
Hi All,
I have been trying to find a easy way to make it so any approvals older than 14 days will auto reject and then fire off a notification on why its being rejected. Has anyone else had any luck with this? I have tried approval rules based on create time etc and they don't seem to mark as rejected. Does this need to be a business rule instead? If so does anyone have one they could provide?
Thanks!
Steve
- Labels:
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2014 05:32 AM
Option 1 :
Write a business rule on insert of Approval record.
This business rule will create a record in sys_trigger table.
Basically you are creating a scheduled script that will run after 14 days.
In this script, you will check if the approval record is still in requested state. If yes, the state will be changed to rejected.
Option 2:
Create a daily job that will query all the approval record to check if there is any approval record created before 14 days and still in requested state.
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('state','requested');
gr.addQuery('sys_created_on','<',gs.daysAgo(14));
gr.query();
if (gr.next())
{
gr.state = 'rejected';
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2014 05:46 AM
warning with the option 1: could be a root cause for "server performance" issue (if the workers are too heavily used because the amount of approvals is too important), the business justification for this technical option has to be strong and mandatory.
warning with the option 2: It's working only if the approval doesn't go to "not yet requested" state, probably the case of 90% of requirements but definitively not 100% of the cases.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-25-2024 07:19 AM
Hi Bhavesh,
The script is working fine but one issue in this.
it is working for all approvals like RITM, change, knowledge etc.
If we want to reject only RITM approvals, then what logic can work here.
Could please help on this.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2014 05:34 AM
Hi magoo,
I would suggest two ways of doing that:
1 - Overnight job running every 24h looking for open approvals and closing them, with the reason and everything.
2 - A job created automatically for every approval scheduled to run on 14 days, and if the approval is not approved yet, it rejects it and sets the reason as well.
I personally would go for the option 1.
Creating a Scheduled Job - ServiceNow Wiki\
Thanks,