Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Encoded query for exactly 60 days and 90 days

Richard Thomas2
Tera Contributor

Hi all,

I've trying to set up a scheduled job that runs daily and identifies records exactly 60 days old and 90 old to notify the user to update.

I initially used encoded query active=true^sys_updated_onRELATIVELT@dayofweek@ago@60 and the same for 90 but that sends the user a daily email - I only want to send it once. I also tried the below without success

sys_created_onRELATIVEGT@dayofweek@ago@59^sys_created_onRELATIVELT@dayofweek@ago@61

Does anyone have any experience of scripting something like this?

Appreciated as always!

 

Richard

 

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Richard Thomas 

You can check script shared by Mahendra and share us the updates.

Regards
Ankur

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

Craig Steel - F
Tera Guru

If anyone is coming to this thread lately, the original poster was close to correct.  

I had a similar requirement, except mine was looking for records exactly 90 days in the future.

In the below example, u_expiration is a date time field some time in the future.  My requirement was to find records which were 90 days in the future, and triggering a notification based on that record.

 

The list filter is:

Expiration After Relative 89 days from now + Expiration Before Relative 91 days from now

or

u_expirationRELATIVEGT@dayofweek@ahead@89^u_expirationRELATIVELT@dayofweek@ahead@91

 

When working with date/time fields, given time zone differences, this may be contingent on when in the day the search is run (if from a scheduled job), and when the date/time stamp was set.  But the above is the general idea.