Want to Triger email Notification to the user when incident is pending for customer action more than 7 days.

Abhishek66
Tera Contributor

Hi Developers,

Please help on below.

Want to Triger email Notification to the user when incident is pending for customer action more than 7 days.

 

Steps i have performed -

1- Created the Notification by using email templet.

2- Created the event in registry with name of (GBP.7days)

Now I want to write a business rule to trigger notification on 7th working day.

Kindly Help.

 

 

6 REPLIES 6

shloke04
Kilo Patron

Hi,

There is a OOB field Named as "Follow Up" which you can utilize here. So what you need to do here is:

1) Write a Before Update business rule first which will set the value of Follow Up field on Incident when Incident is put to Awaiting Customer info.

2) Now you need to set this field as 7th working day.

3) Now write a Scheduled Job which will check for this date field and will trigger the notification which you want.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Nishu Saini
Kilo Guru
Kilo Guru

Use the schedule job to run on weekdays. Check the updated time in the incident if the current - updated date >7 . Call the event in the script use DateTime class and difference function to subtract the dates.

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi Guru,

 

The below thread might help in your case.

Send email notifications for pending incident

 

Regards,

Gunjan


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

shloke04
Kilo Patron

So to support my answer, I have listed down the steps as well:

1) Create a Before Update Business Rule on Incident table and use the script below:

BR Details:

Table Name: Incident

When: Before Update

Condition: State Changes to On Hold and On Hold Reason is Awaiting Caller

Script:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var createdDate = new GlideDateTime(current.sys_updated_on);
    
	var daysValue = 7;
   

    // add days to updated date

    createdDate.addDaysUTC(daysValue);

    // if after adding days it comes as saturday i.e. day as 6 so add 2 days so that it comes to Monday
    // if after adding days it comes as sunday i.e. day as 7 add 1 day so that it comes to Monday

    if (createdDate.getDayOfWeekUTC() == 6)
        createdDate.addDaysLocalTime(2);

    else if (createdDate.getDayOfWeekUTC() == 7)
        createdDate.addDaysLocalTime(1);

    current.follow_up = createdDate;

})(current, previous);

find_real_file.png

Now the above script will add 7 business days to the Follow up field when the Incident was moved to Awaiting caller status.

Now write a Scheduled Job and use the script below which will check for this follow up field and fire your event to trigger the Notification:

triggerEmail();

function triggerEmail(){
	var gr = new GlideRecord('incident');
	gr.addEncodedQuery('state=3^hold_reason=1^follow_upONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
	gr.query();
	while(gr.next()){
		gs.eventQueue('Event Name', gr,gr.caller_id,gs.getUserID());
	}
}

Now just configure your Notification and make sure to select and make it event based and check the below parameter in Notification form as mentioned below:

Parm1

Parm2

Send to Event Creator.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke