How to auto populate user id by using first&last names in user table

vinod8008
Kilo Explorer

how to auto-populate user id with the business rule.please provide example script.

 

Thankq

3 REPLIES 3

Shishir Srivast
Mega Sage

you can try with below script in After insert Business Rule on sys_user table.

 

(function executeRule(current, previous /*null when async*/) {
current.user_name = current.first_name + '&' + current.last_name;
})(current, previous);

 

if there is any other format you need to form then you can change the script accordingly. but using this way I am not sure how you will maintain the unique user id if first_name and last_name are same for many users.

Tushar Sharma2
Kilo Guru

Hello Vinod,

 

Please confirm if you need to auto generate user ID using First and last name from business rule?

 

Regards,

Tushar

 

Ashutosh Munot1
Kilo Patron
Kilo Patron

HI,

 

I will suggest to use before Insert BR on sys_user table.

(function executeRule(current, previous /*null when async*/) {
current.user_name = current.first_name + '.' + current.last_name;
})(current, previous);

So here you dont need to update the record again.


In after BR you will need to put current.update as well at the end.

 

Thanks,
Ashutosh

 

Please mark as helpful or correct.