From 0c266756c94cc76259c00cf7e555d9b6f6a0bd31 Mon Sep 17 00:00:00 2001 From: Tim Dingle Date: Fri, 25 Oct 2024 17:26:15 -0500 Subject: [PATCH 1/2] Create Business Rule Triggers an event for a notification when someone is added to a list and parses their first name. --- Business Rules/Business Rule | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Business Rules/Business Rule diff --git a/Business Rules/Business Rule b/Business Rules/Business Rule new file mode 100644 index 0000000000..5e6bc78fd1 --- /dev/null +++ b/Business Rules/Business Rule @@ -0,0 +1,19 @@ +A business rule to trigger an event on a notification when someone is added to a list. It also parses a user's first name. + +(function executeRule(current, previous /*null when async*/) { + + // Assuming you are getting the list of added users from the watchlist + var addedUsers = current..split(','); + + // Loop through the added users to trigger the event for each + addedUsers.forEach(function(userID) { + // Get the user record to retrieve first name + var userGr = new GlideRecord('sys_user'); + if (userGr.get(userID)) { + + // Fire an event for each user with their first name + gs.eventQueue('’, current, userID, userGr.first_name); + } + }); + +})(current, previous); From 55657c492126cde67cfa91959c44d05329cba1f3 Mon Sep 17 00:00:00 2001 From: Tim Dingle Date: Wed, 30 Oct 2024 11:10:36 -0500 Subject: [PATCH 2/2] Create Business rule to call an event --- Notifications/Business rule to call an event | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Notifications/Business rule to call an event diff --git a/Notifications/Business rule to call an event b/Notifications/Business rule to call an event new file mode 100644 index 0000000000..daa680de59 --- /dev/null +++ b/Notifications/Business rule to call an event @@ -0,0 +1,17 @@ +(function executeRule(current, previous /*null when async*/) { + + // Assuming you are getting the list of added users from the watchlist + var addedUsers = current..split(','); + + // Loop through the added users to trigger the event for each + addedUsers.forEach(function(userID) { + // Get the user record to retrieve first name + var userGr = new GlideRecord('sys_user'); + if (userGr.get(userID)) { + + // Fire an event for each user with their first name + gs.eventQueue('’, current, userID, userGr.first_name); + } + }); + +})(current, previous);