Skip to content

Prevent unnecessary notifications from being sent out #1516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Create a GlideRecord object for the 'sys_email' table
var emailGR = new GlideRecord('sys_email');

// Query for the emails you want to ignore (adjust the query as needed)
emailGR.addQuery('state', 'ready'); // only those mails which are ready to send
emailGR.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()"); // Optional query to set timeline if not required we can comment this.
emailGR.query();

// Loop through the results and mark them as 'Ignored'
while (emailGR.next()) {
emailGR.state = "ignored"; //setting state to "ignored"
emailGR.type = 'send-ignored'; // Set the type to 'ignored'
emailGR.updateMultiple(); // Save the changes
}

gs.info('All relevant emails have been marked as ignored.');
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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.

We are querying the sys_email table to find all the emails with below queries:
--> emails with state as "ready"
--> emails that were created on today (optional query, if not added all the mails with state as "ready" will be considered for getting ignored.)

Post query we are setting as below:
--> state of the email to "ignored"
--> type of the email to "send-ignored"

After setting the fields we are updating the records.

Please be cautious while using the script in Production environment.