One daily email reminder to the user which contains all pending approvals of that user.

Adityanshu Sing
Tera Contributor

Can someone suggest the scheduled job and email script which send the single notification to the user which have one or more that one pending approvals except change approvals and also include the link of "view all approvals " on portal.

2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Adityanshu Sing ,

 

Can you try below code n let me know if it works for u or not 

 

var gr = new GlideRecord('sysapproval_approver');
        gr.addQuery('state', 'requested');
        gr.addQuery('sys_class_name', '!=', 'change_request'); // Exclude change approvals
        gr.groupBy('approver'); // Group by approver
        gr.query();
        while (gr.next()) {
            var userId = gr.approver.toString();
            var user = new GlideRecord('sys_user');
            if (user.get(userId)) {
                var email = user.email;
                var link = gs.getProperty('glide.servlet.uri') + 'my_approvals.do';
                var message = 'Hello ' + user.name + ',\n\n';
                message += 'You have pending approvals. Click the link below to view all your approvals:\n'
                message += link;
                // Queue the email for sending asynchronously
                gs.eventQueue('email.send', user, email, 'Pending Approvals Notification', message);
            }
        }

    

 

Create a notification which should trigger when above event is fired

 

Thanks,

Danish

 

 

Jaspal Singh
Mega Patron
Mega Patron

Hi Aditya,

Check for article. Also, you can check.