Send Approver notification if created more then 3 days

germc
Giga Expert

Hi guys,

We are doing some work around sending approval notification reminders and we have a solution implemented whereby they are sent out every 3 days.

However, we want to also add a condition that reminder is not sent unless the approval is more than 3 days old. Is this possible?

So this is where we are at so far:

  • Created new event:

find_real_file.png

  • Created notification to send when even is fired.
  • Created a schedule o run periodically every 3 days with the following script:

var gr = new GlideRecord('sysapproval_approver');

      gr.addQuery('state', 'requested');

      gr.addQuery('sysapproval.sys_class_name','sc_request');

      gr.query();

      while (gr.next()) {

          gs.eventQueue("approval.reminder",gr, gs.getUserID(), gs.userName());

      }  

This is how the schedule looks:

find_real_file.png

Has anyone achieved it so that reminder is not sent unless the approval is more than 3 days old? Field is called 'sys_created_on'.

6 REPLIES 6

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Gerard,



When I'm looking to add queries based on dates, I usually use encoded queries since it's really easy to generate them from a list.



54801e744f.png



Then you can just add this line to your existing query:


gr.addEncodedQuery('sys_created_onRELATIVELE@hour@ago@72');


Hi Gerard, We can achieve this by using a workflow. we had a requirement in which we have to generate a reminder email after 5 days.
Find the below steps
1)Create a property in which you define the value 72.
2)In workflow you can add like that - var time = gs.getProperty('property name'); time = time * 3600; answer = time; // it will give you time lag of three days
3) After that you can check your conditions if satisfy, trigger notification and point to the timer again.



Thanks Varun Monga
PS: Hit like, Helpful or Correct depending on the impact of the response


Will the Created <=javascript:gs.hoursAgo(72) get the time 3 Days ago from now or time of 3 Days after the created date?


What we want is to not email the reminder when the approval is less than 3 days old.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Gerard,



It would get the time three days ago from now, then not send the reminder if it was less than three days ago.