Daily Approval reminder emails

New user1212
Tera Contributor

Hi,
I need to create a reminder about approvals that will go out every day at 1 p.m.
I don't want to do it via workflow... I've tried methods from various articles, but I have the impression that there's always something missing because these solutions don't work for me.
Can anyone help, step by step on how to create them?

7 REPLIES 7

Deepak Shaerma
Kilo Sage

Hi @New user1212 
Use Scheduled jobs to trigger the reminder for approvals daily at specific time..
System Definition>> Scheduled Jobs >> Create NEW>> Script type

(function executeJob() {
    var approvalGr = new GlideRecord('sysapproval_approver');
    approvalGr.addQuery('state', 'requested'); // or use the appropriate field and value for pending approvals in your case
    approvalGr.query();

    while (approvalGr.next()) {
        // Assuming ‘approver’ is the user reference field in the sysapproval_approver table
        var approverId = approvalGr.getValue('approver');

        if (approverId) {
            // Create and configure the email
            var email = new GlideEmailOutbound();
            email.setSubject('Reminder: Approval Pending');
            email.setFrom('your_email@example.com'); // Set an appropriate sender address
            email.addRecipient(approverId); // Add the approver as the recipient

            // Construct the email body
            var emailBody = 'Dear ' + approvalGr.approver.getDisplayValue() + ',<br>';
            emailBody += 'You have a pending approval request. Please review it at your earliest convenience.<br>';
            emailBody += 'Details: ' + approvalGr.document_id.getDisplayValue() + '<br><br>';
            emailBody += 'Thank you.';

            email.setBody(emailBody);

            // Send the email
            email.send();
        }
    }
})();

Adjust the script and fields in the script according to your requirements.
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma 

Novira Sundberg
Tera Expert

 Hi, 

You can do via scheduled job that is set to run daily at 1 PM, to trigger events, and in turn a notification will be triggered when event runs!

 

Step 1. Create an event on event > registry something like "approval.reminder.daily"  trigger by scheduled job, keep table empty, write description what this event is about

 

Step 2. Create notification to be triggered. 

Send when event is fired

Put your event name 

update all other information 

 

Step 3 Create scheduled job to trigger the event created

check the advanced check box 

Run daily at 1 pm

Put the script to trigger event created

 

var gr = new GlideRecord("sysevent_email_action");
gr.addQuery("sys_id", "xxxxxxxxxx"); //sys id of  notification
gr.query();
while (gr.next()) {

// gs.log("table " + gr.name + " name ");

gs.eventQueue('your event name", gr);
}

 

Step 4. Check on outbox and system log or event log if the event and notification got triggered. 

 

Good luck!

 

//Novira

 

 

 

shows an error in the code

On scheduled job, choose run as system admin, and class choose as scheduled script execution. 

On notification, what table you have?

Can you post your code on scheduled job?