- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2021 02:52 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 12:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2021 11:37 PM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2021 11:47 PM
Hi
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 12:01 AM
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
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2021 05:22 AM
Thank you Ankur. It is working.
Stay safe.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-21-2022 08:06 PM
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