Skip to content

Commit 5130eee

Browse files
authored
Autogenerate unique mail for onboarded users
Whenever new users onboarded BR will automatically create unique mail to the user and update it to user record
1 parent 2c8e071 commit 5130eee

File tree

1 file changed

+22
-0
lines changed
  • Server-Side Components/Business Rules/Auto Generate Unique Emails for New Users

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
3+
// Get Name and User id values
4+
var cleanName = current.name.replace(/,/g, '').trim();
5+
6+
var nameParts = cleanName.split(/\s+/);
7+
8+
var initials = '';
9+
for (var i = 0; i < nameParts.length; i++) {
10+
if (nameParts[i].length > 0) {
11+
initials += nameParts[i][0].toUpperCase();
12+
}
13+
}
14+
15+
// Create email alias
16+
var emailAlias = initials.toLowerCase() + '.' + current.user_name.toLowerCase() + '@company.com';
17+
18+
// Set output value to email field
19+
current.email = emailAlias;
20+
current.update();
21+
22+
})(current, previous);

0 commit comments

Comments
 (0)