-
Notifications
You must be signed in to change notification settings - Fork 683
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
Lacah
merged 7 commits into
ServiceNowDevProgram:main
from
koratalas:Prevent-Unnecessary-notifications-from-being-sent-out
Oct 29, 2024
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f251bf4
Create Prevent_unnecessary_notifications_from_being_sent_out.js
koratalas 3aed752
Create readme.md
koratalas 777b10d
Update Prevent_unnecessary_notifications_from_being_sent_out.js
koratalas 5bbdcc4
Merge branch 'main' into Prevent-Unnecessary-notifications-from-being…
koratalas 6172b6d
Merge branch 'ServiceNowDevProgram:main' into Prevent-Unnecessary-not…
koratalas a9eb5d5
Update Prevent_unnecessary_notifications_from_being_sent_out.js
koratalas 58cfb2d
Merge branch 'main' into Prevent-Unnecessary-notifications-from-being…
koratalas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...otifications from being sent out/Prevent_unnecessary_notifications_from_being_sent_out.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); |
15 changes: 15 additions & 0 deletions
15
Background Scripts/Prevent unnecessary notifications from being sent out/readme.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.