How to change state of RITM when Approval is rejected automatically by a Scheduled Job
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 09:36 PM
Here is the scenario:
When approval is rejected by the approver, then state of RITM changes to 'Cancelled'. This is performed by a workflow and is working perfectly.
In case if the approver takes no action for 15 days, then RITM is auto rejected. Upon Auto rejection we want to set the 'State' as 'Closed'.
I have written 1 schedule job for the same(screenshot attached).
But it is not working.
Any help will be appreciated.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 11:50 PM
Hi Sudhachandan,
I have created one scheduled as per your request. And it is working fine for me.
So you can change the conditions little bit if you want to modify the script.
Please mark this answer correct if it resolved the query and mark it helpful too if it helped you at all.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 01:53 AM
just edit one line in encoded query as it should not check already rejected records so encoded query will be like:
app.addEncodedQuery('sys_updated_on<=javascript:gs.beginningOfLastMinute()^sysapprovalSTARTSWITHRITM^state!=rejected');
Update this in my schedule job as shown above.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 03:30 AM
Thank you for your response.
So we can achieve this with only schedule job?
Business rule which you provided earlier is not required, right?
Please let me know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 03:48 AM
Yes, We can achieve this with only schedule job, initially i wrote BR because i thought you are only cared about the rejected state and there is no time related with this like 15 days and all.
Now you can achieve this with the script i have provided. You can modify it as per your exact request and get the work done.
Thanks,
Mohit Kaushik
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 04:08 AM
Thank you,
Mohith, I have 1 question here.
In the Schedule job you have provided above, can you please let me know, which line of Code will check that RITM approval has not been provided for 15 days?