Skip to content

Commit 185759c

Browse files
authored
Prevent unnecessary notifications from being sent out (#1516)
1 parent cf4887a commit 185759c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var emailGR = new GlideRecord('sys_email');
2+
3+
// Query for the emails you want to ignore
4+
emailGR.addQuery('state', 'ready'); // Only emails that are ready to send
5+
emailGR.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()"); // Optional timeline filter
6+
7+
// Set the fields to ignore and update all matching records at once
8+
emailGR.setValue('state', 'ignored'); // Set state to "ignored"
9+
emailGR.setValue('type', 'send-ignored'); // Set type to 'send-ignored'
10+
emailGR.updateMultiple(); // Bulk update all matching records
11+
12+
gs.info('All relevant emails have been marked as ignored.');
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Created a background script to prevent unnecessary notifications from being sent out.
2+
It helps in managing the volume of emails being sent so that we do not send the notifications even by mistake.
3+
This script is mostly used in dev or uat to avoid any notifications being sent from lower instances.
4+
5+
We are querying the sys_email table to find all the emails with below queries:
6+
--> emails with state as "ready"
7+
--> emails that were created on today (optional query, if not added all the mails with state as "ready" will be considered for getting ignored.)
8+
9+
Post query we are setting as below:
10+
--> state of the email to "ignored"
11+
--> type of the email to "send-ignored"
12+
13+
After setting the fields we are updating the records.
14+
15+
Please be cautious while using the script in Production environment.

0 commit comments

Comments
 (0)