- 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 08:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2021 08:21 AM
Did any of the record has 30 days or 60 or 90 days as difference.
please test with correct records
are you having user field on your table which refers sys_user table
In Email notification is Event Parm1 contains recipient checkbox checked
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 08:31 AM
Hi,
Did any of the record has 30 days or 60 or 90 days as difference?
No Ankur, the records were 7days old.
please test with correct records. -- We are testing for records that are having created date less than 5days from now right. So 30days old records are not required? And I have created new records also, but no result.
are you having user field on your table which refers sys_user table?
I don't have custom field, I have created by OOB field.
In Email notification is Event Parm1 contains recipient checkbox checked?
I checked it to true and tested again, but not working.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2021 10:22 PM
So are you testing with 5 days as difference between created time and now time?
Are there any records matching your condition of date/time difference
Try adding logs in the job script
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:22 PM
Hi
are you testing with 5 days as difference between created time and now time?
Yes Ankur, according to requirement, the notification should be sent for every 24hours upto 5days from the created date. If created date exceeds 5days then notification should be stopped.
In my instance, there are 11 records, which match with condition (days < 6)in the script and the script is working fine as it shows 11 log entries.
But notification is not getting triggered.
I have chosen Scheduled Script Execution under scheduled jobs and written below script there:
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);
// if the difference is less than 6
if(days < 6){
gs.eventQueue('notification.remainder', gr, gr.sys_created_by);
gs.log('check if condition: ');
}
}
}
catch(ex){
gs.info('Exception'+ex);
}
}
Notification: