How to auto close Request if no action taken after 2 days of Date of Dispatch field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2022 02:21 AM
Hi Team,
I have a Record Producer which is mapping to a table u_physical_security.
Record Producer is having a variable called Date of Dispatch this variable is mapped to u_physical_security table's field Date of Dispatch.
Workflow running for this RP is having three level of approvals and multiple catalog tasks. First approval generated - It got approved then 2nd approval generated - t got approved the 3rd approval generated. After that tasks generated for u_physical_security_task.
My requirement is- If no action is taken after 2 days of Date of Dispatch field then auto close the Physical Security Task and Physical security request.
This action can be on any level of approvals or tasks- If no action is taken on approval after 2 days of Date of dispatch then set approval as No longer required and auto close Physical security request.
if first approval is approved and then no action is taken after 2 days of Date of dispatch on 2nd approval then set approval as No longer required and auto close Physical security request.
If all approval approved and task generated then if no action is taken after 2 days of Date of dispatch on2nd task then close Physical security task and Physical security request.
Please help me to get this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 03:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 04:07 AM
as you can see. that a reccord is still pending.
also copy the first input that is a encoded query and paste it in you table to see the result for it

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 04:09 AM
or execute the below script to get the sys_id of the child record that is still pending
var gr = new GlideRecord('u_physical_security_task');
gr.addQuery('parent', '75a002b38725cd102ad9840acebb35a1'); //sys_id is of Parent record
gr.addQuery('state','!=','3'); // checking if any records with state is not 3
gr.query();
gs.info(gr.getEncodedQuery());
if(gr.next()) {
gs.info("still record is pending. " +gr.sys_id);//printing the sys_id of the open task
return 'no'
}
gs.info('all tasks are close')
return 'yes';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 05:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 06:27 AM
answer = checkState();
function checkState() {
var gr = new GlideRecord('u_physical_security_task');
gr.addQuery('parent', '75a002b38725cd102ad9840acebb35a1'); //sys_id is of Parent record
gr.addQuery('state','!=','3'); // checking if any records with state is not 3
gr.query();
if(gr.next()) {
return 'no'
}
return 'yes';
}
add this in your if condition acitvity. then it should work