Skip to content

Commit f251bf4

Browse files
authored
Create Prevent_unnecessary_notifications_from_being_sent_out.js
Created a background script to prevent unnecessary notifications from being sent out. It helps in managing the volume of emails being sent so that we do not send the notifications even by mistake. This script is mostly used in dev or uat to avoid any notifications being sent from lower instances.
1 parent 26a2502 commit f251bf4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Create a GlideRecord object for the 'sys_email' table
2+
var emailGR = new GlideRecord('sys_email');
3+
4+
// Query for the emails you want to ignore (adjust the query as needed)
5+
emailGR.addQuery('state', 'ready'); // only those mails which are ready to send
6+
emailGR.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()"); // Optional query to set timeline if not required we can comment this.
7+
emailGR.query();
8+
9+
// Loop through the results and mark them as 'Ignored'
10+
while (emailGR.next()) {
11+
emailGR.state = "ignored"; //setting state to "ignored"
12+
emailGR.type = 'send-ignored'; // Set the type to 'ignored'
13+
emailGR.update(); // Save the changes
14+
}
15+
16+
gs.info('All relevant emails have been marked as ignored.');

0 commit comments

Comments
 (0)