Handling of Requested Approvals for sc_req_item

LokeshwarReddy
Tera Contributor

Objective:

Create a scheduled job to manage requested approvals for sc_req_item records. The job will send notifications on the 4th and 6th day of requested approval and cancel the request along with associated approvals after the 8th day.

Detailed Requirements:

  1. Scheduled Job:

    • Name: RequestedApprovalNotification
    • Frequency: Daily
    • Functionality:
      • Query sc_req_item records where the approval field is requested and the sys_created_on date is more than 5 days ago.
      • Send notifications on the 5th and 7th day of requested approval.
      • Cancel the request and associated approvals after the 8th day.
  2. Notification Functionality:

    • Function Name: sendApprovalNotifications
    • Input: sys_id of sc_req_item
    • Functionality:
      • Check if the email has already been sent.
      • If not, trigger an event to send an email to the requestor and CC all approvers.
  3. Cancellation Functionality:

    • Function Name: cancelRequestAndApprovals
    • Input: sys_id of sc_req_item
    • Functionality:
      • Cancel the sc_req_item request.
      • Cancel all associated approvals in the sysapproval_approver table.
  4. Retrigger Approval Notifications:

    • Function Name: retriggerApprovalNotification
    • Input: Approval record
    • Functionality:
      • Trigger the "approval.inserted" event to resend the approval email.

Implementation Steps:

  1. Create Scheduled Script Execution:

    • Define the script to query requested approvals and handle notifications and cancellations.
  2. Create Notification Events:

    • Define events for approval.notification and approval.cancelled.
  3. Create Notifications:

    • Set up email notifications for the defined events.
  4. Define Functions:

    • Implement the sendApprovalNotifications, cancelRequestAndApprovals, and retriggerApprovalNotification functions in a Script Include.
2 REPLIES 2

Brian Lancaster
Tera Sage

I have something similar but instead of using a scheduled job I have a flow that gets attached to the approval records once it is created. The only difference is that we do 6 days instead of 8 with 2 reminder notifications.

BrianLancaster_0-1748962650783.png

 

Alp Utku
Mega Sage

Please see the following video : https://www.youtube.com/watch?v=hVctTUMWIcs 

Community Article : https://community.servicenow.com/community?id=community_blog&sys_id=1fe969a71b9c1010fff162c4bd4bcb45