Notification help.

pramn
Tera Guru

Hi Team , 

Can you Please guide me with below request 

SNOW send a daily automated notification to requestor of the CR and his/her Manager if the CR has passed the (scheduled) planned end date and still not in any one of the below terminal state: Closed Complete, Cancelled, Closed Exceptions

2 ACCEPTED SOLUTIONS

Vrushali  Kolte
Mega Sage

Hello @pramn ,

 

To send daily automated notification, you need to create a scheduled script execution & notification.

Create a Scheduled Script Execution

  1. Navigate to: System Definition > Scheduled Script Executions.

  2. Click on: New to create a new scheduled script.

  3. Configure the Scheduled Script Execution:

    • Name: Notify Requestor and Manager of Overdue CRs
    • Active: True
    • Run: Daily
    • Time: Choose a suitable time for the script to run daily (e.g., 12:00 AM).
    • Condition: Leave this blank as we will handle the condition in the script.
  4. Script:

 

 

    var gr = new GlideRecord('change_request');
    gr.addEncodedQuery('planned_end_date<javascript&colon;gs.beginningOfToday()^stateNOT IN3,4,7'); // Adjust states as per your instance
    gr.query();

    while (gr.next()) {
        var requestor = gr.requested_by;
        var manager = requestor.manager;

        // Check if the manager is not empty
        if (manager) {
            var recipients = requestor.email + ',' + manager.email;

            // Send the notification
            gs.eventQueue('event_name', gr, recipients); //Pass the correct event name
        } else {
            // Send notification only to requestor if manager is not defined
            gs.eventQueue('event_name', gr, requestor.email); //
        }
    }

 

 

 

Then register an event and configure the notification record as below -

Configure the Notification:

  • Name: Overdue CR Notification
  • Table: Change Request
  • When to send: Event is fired
  • Event name: select event.
  • Who will receive: Select use the recipients from the event checkbox.

 

For more information please refer -

 

https://www.servicenow.com/community/now-platform-blog/trigger-notification-by-throwing-an-event/ba-...

https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/notification...

 

If my answer solves your issue, please mark it as Accepted✔️ & Helpful👍!

View solution in original post

Hello @pramn ,

 

Here you go -

VrushaliKolte_0-1722406048852.png

VrushaliKolte_1-1722406054401.png

Navigate to System definition > Scehduled Jobs > click on New Button > Automatically run a script of your choosing 

 

For more information on scheduled Jobs please refer -

https://developer.servicenow.com/dev.do#!/learn/learning-plans/washingtondc/new_to_servicenow/app_st...

 

If my answer solves your issue, please mark it as Accepted ✔️& Helpful👍!

View solution in original post

3 REPLIES 3

Vrushali  Kolte
Mega Sage

Hello @pramn ,

 

To send daily automated notification, you need to create a scheduled script execution & notification.

Create a Scheduled Script Execution

  1. Navigate to: System Definition > Scheduled Script Executions.

  2. Click on: New to create a new scheduled script.

  3. Configure the Scheduled Script Execution:

    • Name: Notify Requestor and Manager of Overdue CRs
    • Active: True
    • Run: Daily
    • Time: Choose a suitable time for the script to run daily (e.g., 12:00 AM).
    • Condition: Leave this blank as we will handle the condition in the script.
  4. Script:

 

 

    var gr = new GlideRecord('change_request');
    gr.addEncodedQuery('planned_end_date<javascript&colon;gs.beginningOfToday()^stateNOT IN3,4,7'); // Adjust states as per your instance
    gr.query();

    while (gr.next()) {
        var requestor = gr.requested_by;
        var manager = requestor.manager;

        // Check if the manager is not empty
        if (manager) {
            var recipients = requestor.email + ',' + manager.email;

            // Send the notification
            gs.eventQueue('event_name', gr, recipients); //Pass the correct event name
        } else {
            // Send notification only to requestor if manager is not defined
            gs.eventQueue('event_name', gr, requestor.email); //
        }
    }

 

 

 

Then register an event and configure the notification record as below -

Configure the Notification:

  • Name: Overdue CR Notification
  • Table: Change Request
  • When to send: Event is fired
  • Event name: select event.
  • Who will receive: Select use the recipients from the event checkbox.

 

For more information please refer -

 

https://www.servicenow.com/community/now-platform-blog/trigger-notification-by-throwing-an-event/ba-...

https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/notification...

 

If my answer solves your issue, please mark it as Accepted✔️ & Helpful👍!

Its a schedule job or scheduled script execution , i am not able to find .please help me with this 

Hello @pramn ,

 

Here you go -

VrushaliKolte_0-1722406048852.png

VrushaliKolte_1-1722406054401.png

Navigate to System definition > Scehduled Jobs > click on New Button > Automatically run a script of your choosing 

 

For more information on scheduled Jobs please refer -

https://developer.servicenow.com/dev.do#!/learn/learning-plans/washingtondc/new_to_servicenow/app_st...

 

If my answer solves your issue, please mark it as Accepted ✔️& Helpful👍!