How to get different userID and email for the same fname, lname wen submitted the record producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2023 02:36 AM
Need script to update userid as userid, userid0 , userid1 and email as test.abc@gmail.com , test.abc0@gmail.com etc.
each time when we submit the form using same first name and last name, as organisation may have multiple users having same name. So that there wont be any duplicates.
When im trying to code, values are getting updated in the same profile, but not generating new profiles and new userids and email like userid0,userid1 , test.abc0@gmail.com etc
Attached OOTB script include(hr_sysUser), where the logic of userid from firstname and lastname mentioned.
Userid code :
(function executeRule(current, previous /*null when async*/) {
var fname = current.first_name;
var lname = current.last_name;
var firstLetter = fname.slice(0,1);
var count = (gs.getProperty("sn_hr_core.profile.max.tries", 50));
for (var suffix = 0; suffix < count; ++suffix) {
var userName = firstLetter + lname +suffix;
current.user_name=userName;
current.update();
}
}
Email Field code:
(function executeRule(current, previous /*null when async*/) {
var first = current.first_name;
var last = current.last_name;
var count = (gs.getProperty("sn_hr_core.profile.max.tries", 50));
for (var suffix = 0; suffix < count; ++suffix) {
var userName = first + "." + last + suffix + '@gmail.com';
current.email=userName;
current.update();
}
})(current, previous);
- Labels:
-
HR Service Delivery

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 05:59 AM
There are a lot of Script Includes involved right from the record producer submission till the profile generation. Can you try and reduce the order of your business rule on sys_user table (just to make sure that your logic runs first than the OOTB BR) and see if it works as expected.