- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2024 11:37 PM
Hi,
My requirement is if RITM is not approved since 7 days then the approval should get rejected and RITM should get closed incomplete. I tried below script for change request on my PDI and it ran except for approval rejected part since approvers were not there. BUT when I am trying this for RITM on my instance it does not run. Please help me out in finding out the mistake.
I created this property glide.ui.autoreject.time_req with integer value 7 and a schedule job as below:
After business rule as below:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:46 AM
In Scheduled job, current won't work.
so, you can go ahead with gr.sys_id as this will have the RITM sysID.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:33 AM - edited 07-30-2024 02:36 AM
Hi @Harsha34 ,
Try the below:
autoCloseRITM();
function autoCloseRITM() {
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', 'eb3ed899c38302103869d64d05013144'); /// testing this for a single RITM
gr.addEncodedQuery("sys_created_onRELATIVELT@dayofweek@ago@7^approval=requested^active=true"); //This will check for RITM not approved in 7 days from the created date
gr.query();
while (gr.next()) {
var apprRec = new GlideRecord('sysapproval_approver');
apprRec.addQuery('sysapproval', 'eb3ed899c38302103869d64d05013144'); //RITM sysID
apprRec.query();
while (apprRec.next()) {
if (apprRec.state != 'approved') {
apprRec.setValue('state', 'rejected');
apprRec.update();
}
}
}
}
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:40 AM
Hi,
If I want to run this for dynamic RITM and not for a particular one then this should be like below
apprRec.addQuery('sysapproval',current.sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:46 AM
In Scheduled job, current won't work.
so, you can go ahead with gr.sys_id as this will have the RITM sysID.
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:58 AM
Hi,
Thanks a lot :). It worked perfectly.
Hope I will always get your help!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 03:02 AM
Thanks, Happy to assist.
Mark this as Helpful / Accept the Solution if this helps.