to send notification

abhi159
Kilo Sage

i created a record today now after the 4 days i have to send notification how i can do this?

1 ACCEPTED SOLUTION

@abhi159 

 

Sorry for the confusion, please check this script:

 

I assume Schedule job will execute once a day and it will check all the records of a table

 

var days = 4;
var
date = new GlideDateTime();
date.addDaysUTC(-days);
gs.info(date); // this will give 23/11/2023
var gr = new GlideRecord("incident");
gr.addQuery("sys_created_on" ,"<", date);
gr.query();
while(gr.next()){
gs.eventQUeue("TestEvent",gr);
}

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

View solution in original post

5 REPLIES 5

Kai Tingey
Tera Guru

without specific information it's hard to give a specific reply, however one easy solution would be to use a flow to monitor for records in your table that are active, have created on (before) 4 days ago, and / or have updated on (before) 4 days ago - and if so - send an email or trigger a notification. Have it run at whatever interval suits you best.

 

Including updated on field will prevent notifications going out for records that are being actively worked on.

i want to do with scheduled job so i need script for that

Prince Arora
Tera Sage
Tera Sage

@abhi159 

 

1) Create a event for example: TestEvent

2) Create a new notification and add trigger condition when even is fired

3) You can create a schedule job and mention below code in it:

 

var days = 4;
var date = new GlideDateTime();
date.addDaysUTC(days);
var gr = new GlideRecord("NAME_OF_THE_TABLE");
gr.addQuery("sys_updated_on" ,"=", date);
gr.query();
while(gr.next()){
    gs.eventQueue("TestEvent",gr);
}

gr.addQuery("sys_updated_on" ,"=", date);

how this can be equal i want to send notification after 4 days the record created