Need to trigger approval notifications daily for select catalog items

Arka Banerjee1
Tera Contributor

Hi Team,

 

PFB my scheduled script and Notification Body. Please help me in achieving the above. Note that I need to include both the RITM and the approval link in the email.

 

(function() {

    var ritm = new GlideRecord('sc_req_item');
    ritm.addQuery('approval', 'requested');
    ritm.addQuery('cat_item', 'IN',
        '838a577b2b5772d43609f1bfe291bf05,c6e029a5932c83145a2fb5ad1dba10a8,bb02e6252be44bd03609f1bfe291bf8a,b1d60ff52ba80fd03609f1bfe291bf06'
    );
    ritm.addActiveQuery();
    ritm.query();

    while (ritm.next()) {
        notifyApprovers(ritm);
    }

    function notifyApprovers(ritm) {

        var appr = new GlideRecord('sysapproval_approver');
        appr.addQuery('sysapproval', ritm.sys_id);
        appr.addQuery('state', 'requested');
        appr.query();

        while (appr.next()) {
            // Fire an event OR send email directly
            gs.eventQueue(
                'ritm.approval.reminder',
                ritm,
                appr.approver,
                appr.sys_id.toString()
            );
        }
    }

})();
 
ArkaBanerjee1_0-1778150098302.pngArkaBanerjee1_1-1778150130199.png

Please elp me correct this. Thanks!

 

@Ankur Bawiskar 

2 REPLIES 2

Ankur Bawiskar
Tera Patron

@Arka Banerjee1 

so what debugging did you do?

event triggered and processed?

event not triggered?

your notification should have Event parm1 contains Recipient As TRUE

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi Ankur,

 

Event parm 1 contains recepient is set to true. 

 

Now I tried having the notification in sysapproval_approver table. PFB

 

ArkaBanerjee1_0-1778152400259.pngArkaBanerjee1_1-1778152422892.pngArkaBanerjee1_2-1778152448884.png

Its generating an email as below with lots mssing and even the approval link redirecting to the RITM instead of the approval

 

ArkaBanerjee1_3-1778152615637.png

Could you please help resolve this

 

Regards,

Arka