Certainly! If you wish to send out a daily reminder for pending approvals without using workflows in ServiceNow, you can accomplish this through the use of a Scripted Scheduled Job. This approach allows you to have granular control over when and how your reminders are sent out. Here is a step-by-step guide on setting this up:
1. Define Your Requirements
Before creating the job, clarify what types of approvals need reminding (e.g., requests waiting on approval, items in a particular state, etc.) and who the reminder should go to (the approver, a group of users, etc.).
2. Create a Scripted Scheduled Job
- Navigate to System Definition > Scheduled Jobs.
- Click on New to create a new job.
- Select the Type: "Scripted Scheduled Job."
- Fill out the necessary fields:
- Name: Give your job a descriptive name, like "Daily Approval Reminders."
- Run: Select how often you want this job to run. Since you mentioned daily at 1 p.m., you will set up a cron expression for this.
- Cron Trigger: Use the cron expression
0 0 13 * * ? to run the job daily at 1 p.m. server time.
- In the Script field, draft your script to identify pending approvals and send reminders. See the example script below.
3. Example Script
This example illustrates how to send an email to users with pending approval records. You might need to adjust the target table (sysapproval_approver) and conditions according to your specific requirements.
(function executeJob() {
// Define target table and query for pending approvals
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();
}
}
})();
Please adjust "your_email@example.com" to a valid email address from which the reminders should appear to be sent. The example above assumes that sysapproval_approver is the table where approval records are stored, and it specifically targets records in a "requested" state. You'll need to adapt the field checks and references to match the specifics of your approval process.
4. Testing and Validation
After setting up your Scripted Scheduled Job, it is crucial to test:
- Manually run the job to ensure it functions as expected, by navigating to the job in the Scheduled Jobs list and using the "Execute Now" function.
- Check the email logs (System Logs > Emails) to verify that the reminders are being sent out correctly.
- Confirm with the approvers or target recipients that they are receiving the reminders as intended.
Adjust your script and configuration as necessary based on the test outcomes. This step-by-step guide should help you create a daily reminder for approvals accurately reflecting your specific needs in ServiceNow.