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,

Yes I believe that is what your requirement is

Regards
Ankur

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

Hi Ankur,

How to trigger this notification for a record after 24hrs of its creation. And also I didn't find any thing in do until logic to check created has crossed 5days.

Thanks

Hi,

You can create Flow variable which acts like global variable.

Initialize it with 5 and for every run of do until decrement it by 1

In the Do action check if the value of global variable is greater than 0 then execute

Starting from Quebec release you have flow variable

Flow variables

Regards
Ankur

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

Hi @Ankur Bawiskar ,

As I am using Paris version, I am unable to see flow variables option. Can we achieve this with scheduled job script? If yes could you please help me with the script.

Thanks

yes possible via schedule job

Create schedule job which runs daily

refer below sample script

1) find the difference between created time and now time and check if the difference is less than 6

2) if yes then it would send daily email and when the difference is more than 5 it won't send email for that record

sendEmail();

function sendEmail(){
	try{
		var hrProfile = new GlideRecord('sn_hr_core_profile');
		hrProfile.query();
		while(hrProfile.next()){
			var gdt = new GlideDateTime(hrProfile.sys_created_on);
			var nowTime = new GlideDateTime();

			var duration = GlideDateTime.subtract(gdt, nowTime);
			var days = parseInt(duration.getDayPart());

			// if the difference is less than 6
			if(days < 6){
				gs.eventQueue('event_name', hrProfile, hrProfile.user);
			}
		}
	}
	catch(ex){
		gs.info('Exception'+ex);
	}
}

Regards
Ankur

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