How to create a task if the approval is pending for 7 days?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 10:02 AM
Hi All,
I want to create task if the RITM approval is pending for 7 days. I have tried by using the scheduled job but
its only creating 1 task for all the pending approval. How can I create separate task for separate pending approval or
separate RITM approval.
Can anyone please help on this.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 10:05 AM
Hi rakesh
Can you share the script you tried?
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 11:47 PM
Hi Rohila
This the script I tried.
var gr = new GlideRecord("sysapproval_approver");
gr.addQuery('state', 'requested');
gr.addQuery('sys_created_on', '<', gs.daysAgo(1));
gr.query();
if (gr.next()) {
var sct = new GlideRecord('sc_task');
sct.initialize();
sct.short_description = 'Task to check with the approver ';
sct.assignment_group = '63f894991b090510f18ba8ade54bcbd7';
sct.description = gr.document_id.getDisplayValue();
// sct.request_item = current.sys_id;
sct.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 10:06 AM
Hi there,
Instead of scripting this, have you considered a scheduled flow? This would involve zero scripting. Just clicking your logic together through the GUI.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020-2022 ServiceNow Community MVP
2020-2022 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2022 10:09 AM
Hi,
Make use of flow designer and follow the below steps
1.trigger service catalog
2.use lookup records action to search for all the approvals which are created 7 days ago and state is requested.
3.add for each loop action and followed by create catalog task action to create task.
Please mark my response as correct answer or helpful if applicable