Approval Reminder

aniellacerna
Tera Contributor
  1. Create a notification that will remind the approver of an unapproved RITM (Note that you can reuse existing RITMs that satisfies the condition no need to create new catalog item or request a new RITM)
  2. Create a scheduled job that will trigger the notification created above daily but will not run if the current date is out of schedule (8-5 weekdays)
12 REPLIES 12

Sure! In most or all examples, the reminder is sent to the approver added in a request, or in a RITM. However, I wish to send notifications to the approver added in the SCTASK. When you create a request and you dont require an approver, a RITM will be created, and the RITM will create its SCTASK. In the SCTASK there is an "approvers" column, where you can add an approver. I would like to send notifications to this person.

Sure! I will try to explain:

guigilmoura_1-1721660124804.png

guigilmoura_2-1721660149897.pngguigilmoura_3-1721660225307.png

The only thing missing that im not being able to do, is select as recipient(who will receive), the person added as an approver in the SCTASK

 

aniellacerna
Tera Contributor

but what can i do if i only want RITM data to be called

 

Hi @aniellacerna 

 

On sysapproval_approver table we have column as 'Source Table' 

You can add a query in your scheduled job for Source table = Requested Item (sc_req_item)

gr.addEncodedQuery('state=requested^source_table=sc_req_item'); //customized query

 

VishalBirajdar_0-1699602205753.png

 

 

/* Get Day of week */
var date = new GlideDateTime();
var day = date.getDayOfWeek();

/* if not saturday & sunday then run the script */
if (day != 6 || day != 7) {

    /* Get Schedule */
    var shcd = new GlideSchedule('08fcd0830a0a0b2600079f56b1adb9ae'); //sys_id of schedule
    /*Check if date is not in schedule*/
    if (!shcd.isInSchedule(date)) {
        /* Glide record on 'sysapproval_approver' table */
        var gr = new GlideRecord("sysapproval_approver");
        gr.addEncodedQuery('state=requested^source_table=sc_req_item');   //customized query
        gr.query();
        while (gr.next()) {
            /*Send the reminder */
            gs.eventQueue('approval.reminder', gr);
        }
    }else {
		gs.log('Date is in schedule');
	}

}

 

Hope this helps...!!!

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

where did u get the sys id of the schedule?