Skip to content

Commit a9eb5d5

Browse files
authored
Update Prevent_unnecessary_notifications_from_being_sent_out.js
updated to updateMultiple()
1 parent 6172b6d commit a9eb5d5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
// Create a GlideRecord object for the 'sys_email' table
21
var emailGR = new GlideRecord('sys_email');
32

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();
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
86

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.updateMultiple(); // Save the changes
14-
}
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
1511

1612
gs.info('All relevant emails have been marked as ignored.');

0 commit comments

Comments
 (0)