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