How to send notification exactly before 7 days only

chanikya
Tera Guru

Hi ,

Here Request is : i have one field First review date: 25-May-2018

now i would like to send notification exactly 7 days before from First Review Date of records.

Problem is as per my script it is trigger  which records are having 25th, 26th,24,23,22 dates, dates of records are also triggred.

 

 

Schedule Jobs

var apprvog= new GlideRecord('change_request');
apprvog.addEncodedQuery('active=true^u_first_review_dateRELATIVEGE@dayofweek@ahead@7');
apprvog.query();
while(apprvog.next())
{
gs.eventQueue("first_review_date" ,apprvog, apprvog.assigned_to);
}

find_real_file.png

 

find_real_file.png

3 REPLIES 3

Jag5
Tera Guru

Hi Chanikya,

 

you can use the below script. 

 

var apprvog= new GlideRecord('change_request');
apprvog.addQuery('active', true) ;

approvog.addQuery('u_first_review_date', '<=', gs.daysAgo(-7));
apprvog.query();
while(apprvog.next())
{
gs.eventQueue("first_review_date" ,apprvog, apprvog.assigned_to);
}

 

Thanks,

Jag.

 

Please mark CORRECT/HELPFUL as needed.

Hi,

 

Not working......

noorulainatta21
Tera Contributor

Hi,
I was having the same kind of issue, in my case I needed to send a reminder after exactly 7 days of creation if the state was pending but it was giving me the results of all tasks created before 7days  even on the 8th day, 10th day and ones created a month ago. So the query that I am using is

gr.addEncodedQuery('state=-5^sys_created_onRELATIVEGT@dayofweek@ago@8^sys_created_onRELATIVELT@dayofweek@ago@7');
You can try this, As RELATIVEGT@dayofweek@ago@8 is fetching all 8-day records and RELATIVELT@dayofweek@ago@7 is removing 1st 7 days from those. You can use days according to your requirements.
I hope it will help. Thumbs up if it's helpful.
Thank you,