Send notifications for Pending approval after 14 days and 21 to to requested for

srinu8
Tera Contributor

For service catalog Requested Items approval is going to Manger.

1)If the Approval is not approved after 14 days , need  to send notification to  Requested for .

2)The Same approval is not approved after 21 days one more notification should go to the both requested for and manager and also Request should be closed automatically .

 

I need a solution to for all  the Requested Items not for a particular catalog item.

6 REPLIES 6

Kieran Anson
Kilo Patron

A scheduled flow could do this. Perhaps run daily, lookup all approvals for requests/request items where the approval was created 14 days ago and not updated and then trigger a notification. 

 

This would require no code and be easy to maintain 

priyatam_pvp
Tera Guru

@srinu8 

I agree with @Kieran Anson we can do this through flow designer. In case you are trying to do it through schedule job Please refer the below code.

var specificItemSysId = 'xxxxxxxxxxx'; // Replace with the actual sys_id of the catalog item

var grApproval = new GlideRecord('sysapproval_approver'); // Approval Table
var nowDate = new GlideDateTime();
var fourteenDaysAgo = new GlideDateTime();
var twentyOneDaysAgo = new GlideDateTime();

fourteenDaysAgo.addDaysUTC(-14); // 14 days ago
twentyOneDaysAgo.addDaysUTC(-21); // 21 days ago

grApproval.addQuery('state', 'requested'); // Pending approvals
grApproval.addQuery('sys_created_on', '<=', twentyOneDaysAgo); // Approvals older than 21 days
grApproval.query();

while (grApproval.next()) {
var request = grApproval.document_id.getRefRecord(); // Get the related request record

// Ensure it's linked to a Request Item (RITM)
if (request.getTableName() == 'sc_req_item') {
if (request.cat_item == specificItemSysId) { // Check if the Catalog Item matches
if (grApproval.sys_created_on >= fourteenDaysAgo) {
// Send a notification to 'Requested For' at 14 days
gs.eventQueue('approval.reminder.14days', request, request.requested_for, null);
} else {
// Send a notification to 'Requested For' and 'Manager' at 21 days
gs.eventQueue('approval.reminder.21days', request, request.requested_for, request.manager);

// Auto-close the Request
request.state = 'closed';
request.update();
}
}
}
}

Please mark it helpful
Regards
Priyatam

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @srinu8 

 

https://www.youtube.com/watch?v=hVctTUMWIcs

https://www.servicenow.com/community/now-platform-forum/trigger-notification-if-the-approval-is-not-...

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************
How to create a scheduled approval reminder using ServiceNow flow designer. In this video we create a flow triggered on weekly basis to find all approvals open since a certain date and use a for each flow logic and custom create event action to send emails out to approvers. We also add a helpful ...

Shubham_Jain
Mega Sage

@srinu8 

1 - Use a Flow to Monitor Pending Approvals

2 - Send Notifications After 14 & 21 Days

3 - Auto-Close Requests After 21 Days

 

Step 1: Create a Flow in Flow Designer

- Navigate to Flow Designer - Create New Flow

- Name it - Pending RITM Approval Escalation

Add Trigger: Scheduled Trigger

- Run Daily

 

Step 2: Add an Action to Fetch Pending Approvals

-  Add Action -  Lookup Records

 Table: Requested Item (sc_req_item)

- Conditions:

- Approval = Requested

- State not equal to  Closed

- Created on = On or before 14 days ago

 

Step 3: Send Notification After 14 Days

- For Each Record, add Send Notification action

-Recipients: Requested For (requested_for)

- Subject: Pending Approval for Your Request

- Message:

 

Hello ${requested_for.name},
Your request "${number}" has been waiting for approval for 14 days.
Please follow up with your manager.

 

Step 4: Send Notification & Auto-Close After 21 Days

- Add another Lookup Records step

- Conditions:

- Approval = Requested

- State not equal to  Closed

- Created on = On or before 21 days ago

- For Each Record, add Send Notification

- Recipients: Requested For (requested_for) and Approver (approver)

- Subject: Approval Not Received “ Request Closed

- Message:

 

The approval for requested item "${number}" has not been completed within 21 days.
The request has been automatically closed.
If you still need this item, please submit a new request.

Add Update Record Action

- Table: sc_req_item

- Set Approval to Cancelled

- Set State to Closed

 

Step 5: Close Parent Request Automatically

- Add Lookup Records (Check sc_request for related open RITMs)

- If All RITMs are closed, update the sc_request record to Closed

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain