Skip to content

Commit 1ec9ca4

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 a853533 commit 1ec9ca4

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

  • Server-Side Components/Business Rules/Auto Generate Unique Emails for New Users
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];
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)