Skip to content

Commit 0c26675

Browse files
Create Business Rule
Triggers an event for a notification when someone is added to a list and parses their first name.
1 parent aa384d5 commit 0c26675

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Business Rules/Business Rule

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
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.
2+
3+
(function executeRule(current, previous /*null when async*/) {
4+
5+
// Assuming you are getting the list of added users from the watchlist
6+
var addedUsers = current.<list field name>.split(',');
7+
8+
// Loop through the added users to trigger the event for each
9+
addedUsers.forEach(function(userID) {
10+
// Get the user record to retrieve first name
11+
var userGr = new GlideRecord('sys_user');
12+
if (userGr.get(userID)) {
13+
14+
// Fire an event for each user with their first name
15+
gs.eventQueue('<event name>’, current, userID, userGr.first_name);
16+
}
17+
});
18+
19+
})(current, previous);

0 commit comments

Comments
 (0)