How to send notification reminder for every 24hours up to 5days from the record created date.

Ajay37
Tera Contributor

Hi All,

How to send email notification for every 24hrs, until 5days from the creation date.

The first notification should be fired, after 24hrs the record got created. From then, the email should be sent for every 24hrs up to 5days.

Thanks

1 ACCEPTED SOLUTION

Hi,

gr.sys_created_by will give user name and not sys_id or email address

event parm1 requires either user sys_id or user email address

So I mentioned which field on termination task is referring to sys_user? use that field there

So that the event gets the user sys_id

OR if you are having any field on termination task which stores user email then use that there

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

22 REPLIES 22

Hi,

this line won't set the recipient

sendEmail();

function sendEmail(){
    try{
        var gr = new GlideRecord('u_termination_task');
        gr.query();
        while(gr.next()){
            var gdt = new GlideDateTime(gr.sys_created_on);
            var nowTime = new GlideDateTime();
            gs.log("gdt is: " + gdt);
            var duration = GlideDateTime.subtract(gdt, nowTime);
            var days = parseInt(duration.getDayPart());
            gs.log("duration is: " + duration);
            gs.log("days is: " + days); // what came here if it is less than 6 then it should go inside
            // if the difference is less than 6
            if(days < 6){

                // fieldName -> this is the field on termination table which holds user reference

                gs.eventQueue('notification.remainder', gr, gr.fieldName);
                gs.log('check if condition: ');
            }
        }
    }
    catch(ex){
        gs.info('Exception'+ex);
    }
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,

The script is looking same like I updated above and in gr.fieldname, I have give gr.sys_created_by and checked event param1 to true in notification.

Thanks

Hi,

gr.sys_created_by will give user name and not sys_id or email address

event parm1 requires either user sys_id or user email address

So I mentioned which field on termination task is referring to sys_user? use that field there

So that the event gets the user sys_id

OR if you are having any field on termination task which stores user email then use that there

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thank you Ankur. It is working.

Stay safe.

How to send email notification for first 24hrs and thereafter at every 12 hours until the ticket is resolved from the creation date.

The first notification should be fired, after 24hrs the record got created. From then, the email should be sent for every 12 hrs upto ticket get resolved or closed cancelled. Also daily the subject must change. ie first day "Ticket exceeded 24 hrs"   Next day "Ticket exceeded 36 hrs" Next day Ticket exceeded 48 hrs" and so on

Thanks