how to send Notification Reminder to approver for Requested Approvals

Kishore8
Kilo Guru

any body can explain step by step...it will be help full for me....and for other new users also

Can you please explain it step by step.................

i saw previous posts also, but i didn't get any thing ..

1 ACCEPTED SOLUTION

I see I only answered your last question, so here is the rest:


Q: shall we create   both BUSINESS RULE, SCHEDULING JOBS     with same script to run this ,


is it not possible with only   either with Business Rule OR Scheduling jobs.....


A: you can put the script without the start and end lines (include only lines 5 to 16) in the "Run this script" part of the scheduled job. As I said, I prefer everything in one place under the same table, but you can do it only with a scheduled job.



Q: can we set time , i mean i want to run condition after 12.30PM   midnight, where i have to add this condition ,


A: yes - in your scheduled job choose "Daily" as the trigger and set the time of day you want it to run.



harel


View solution in original post

17 REPLIES 17

Brad Tilton
ServiceNow Employee
ServiceNow Employee

If you want to send a reminder email for your approvals older than 3 days, for example, you can create a scheduled job that queries all approvals that were created before 3 days ago, and then iterate through them and refire the approval event to resend the email.


Just stumbled on this older thread, but I was looking for different ways to solve for a re-fire of approval email, and what Brad suggested is pretty much the simplest way to go about this. A scheduled script job that queries against the sysapproval_approvers table for your desired conditions (aging, task type, etc) and re-fires or fires a new event referencing the approval record. The new event then triggers the approval notification, just like it did when it was originally sent.


find_real_file.png


oharel
Kilo Sage

This is how I do it. If anyone else has a shorter, better way, do share.


Create a BR that checks the state of the approval. If state is Requested, generate an event which will trigger a notification. The BR will run daily using a scheduled job (you can do it directly from the job, but I like business rules on the same table).


1. BR:


Name: Email reminder to approver


Table: Approval [sysapproval_approver]


When to run: after


Script:


// run by a scheduled job by the same name


(function executeRule(current, previous /*null when async*/) {



  // Add your code here


  var elapsedTime = 0;


  var currentTimeNow = gs.nowDateTime();


  var gr = new GlideRecord('sysapproval_approver');


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


  gr.query();



  while(gr.next()) {


  elapsedTime = (gs.dateDiff(gr.sys_created_on, currentTimeNow, true)) /60/60/24; //this will check if the approval request was created more than 24 hours prior to checking


  if (elapsedTime >= 1) {//if more than one day has passed...


  gs.eventQueue('this.approval.reminder', gr, gs.getUserID());//fire this event


  }


  }


})(current, previous);



2. create a registry entry for this.approval.reminder on table sysapprover_approval


3. create a notification to be sent upon firing the registry event


Table: sysapproval_approver


When to run: event is fired


Name of event: this.approval.reminder


Who will receive: approver


What it will contain: whatever you want it to contain


4. create a scheduled job:


name: Email reminder to approver


Script:


fcScriptName=Email reminder to approver --> this needs to be the same name as the BR



Trigger type: daily or whatever you need it to be



harel


Thanks for your replay.




in scheduled jobs


what script i should write ,can you please provide it....