Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Username Generation rule check

TheSaviyntBoy
Regular Contributor
Regular Contributor

Hi,

We have a requirement to generate a username:

Check if the user has preferedFirstName -> if yes it should be preferedFirstname.lastname 

else -> firstname.lastname

Autoincrement should also apply to these rules. What would be the right way to do this?

Thank you. 

20 REPLIES 20

PremMahadikar
All-Star
All-Star

Hi @TheSaviyntBoy ,

  • Use Username Generation Rules in Admin -> Global Configurations -> Identity Lifecycle 
  • Use Advanced Config
  • Sample code below
CASE WHEN (preferedfirstname!='' OR preferedfirstname is not null) THEN  replace(concat(preferedfirstname,lastname),' ','') else replace(concat(firstname,lastname),' ','') END 
#
CASE WHEN (preferedfirstname!='' OR preferedfirstname is not null) THEN  replace(concat(preferedfirstname,lastname,1),' ','') else replace(concat(firstname,lastname,1),' ','') END 
#
CASE WHEN (preferedfirstname!='' OR preferedfirstname is not null) THEN  replace(concat(preferedfirstname,lastname,2),' ','') else replace(concat(firstname,lastname,2),' ','') END 

Note: Please use it as reference. The code only has 2 iterations. Please add more while testing and knowing the duplicates in the system.

 

If this helps your question, please consider selecting Accept As Solution and hit Kudos

Hi, 

I tried the above rule, and it gave me the following error: 

TheSaviyntBoy_0-1715612032033.png

Hi tried different combinations like adding 'users.' before the column names, instead of 'is not' I used != and vice versa. 

NM
Esteemed Contributor
Esteemed Contributor

Hi @TheSaviyntBoy , are you trying to create users via saviynt API/UI for via HR import?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

TheSaviyntBoy
Regular Contributor
Regular Contributor

Hi @NM , eventually we will be using HR import, for now, I am testing with CSV feed. 

NM
Esteemed Contributor
Esteemed Contributor

Understood, use the same which @PremMahadikar added .. don't add users. before any property and try 


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

TheSaviyntBoy
Regular Contributor
Regular Contributor

@NM yes I tried that, its not working.

NM
Esteemed Contributor
Esteemed Contributor

@TheSaviyntBoy what are doing you see after making the change?? If you can share that as well..


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

TheSaviyntBoy
Regular Contributor
Regular Contributor

Hi @NM I am getting the following error: 

TheSaviyntBoy_0-1715614300503.png

 

PremMahadikar
All-Star
All-Star

@TheSaviyntBoy , I want to check with you regarding systemusername. Is username being same as systemusername here?

Hi @PremMahadikar

The use of systemUsername isn't decided yet, but yes it can be the same as the username. 

@TheSaviyntBoy , 

If systemusername is same here:

Use the same logic in systemusername generation (Admin -> Global Configurations -> Identity Lifecycle -> Admin System Username Generation Rule)

CASE WHEN (users.preferedfirstname!='' OR users.preferedfirstname is not null) THEN  replace(concat(users.preferedfirstname,users.lastname),' ','') else replace(concat(users.firstname,users.lastname),' ','') END ### case WHEN (users.preferedfirstname!='' OR users.preferedfirstname is not null) THEN  replace(concat(users.preferedfirstname,users.lastname,1),' ','') else replace(concat(users.firstname,users.lastname,1),' ','') end ### case WHEN (users.preferedfirstname!='' OR users.preferedfirstname is not null) THEN  replace(concat(users.preferedfirstname,users.lastname,2),' ','') else replace(concat(users.firstname,users.lastname,2),' ','') end

In username generation logic, call systemusername.

PremMahadikar_0-1715618539847.png

I tested this; it's working. please try!

 

For username generation logic, without any iteration - It's working. With # or ###, it's not generating. If only username should be generated, I would suggest you to use inline preprocessor.

 

If this helps your question, please Accept As Solution and hit Kudos

NM
Esteemed Contributor
Esteemed Contributor

Hi @PremMahadikar , as per my knowledge systemusername rule will only come into picture when we perform operation via import and not at the time of import am I right?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

@NM , I didn't get you. What you mean by 'perform operation via import and not at the time of import'?

NM
Esteemed Contributor
Esteemed Contributor

Hey @PremMahadikar , sorry mixed up the words .. rewriting below 

systemusername rule under global config will only come into picture when we create user from UI and not at the time of import from HR system right?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

@NM , 
Thats okay. This query is clear!

No, it can be also used during job import. In the user import job trigger, you have an option to select 'yes' or 'No'

PremMahadikar_0-1715622546353.png

 

If this helps your question, please Accept As Solution and hit Kudos

NM
Esteemed Contributor
Esteemed Contributor

@PremMahadikar , i meant username.


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

@TheSaviyntBoy , Good to hear it worked!

@NM ,

  • If username is blank during the import, it automatically checks the rule 'Add Register User Rule' and generates as per the logic mentioned. If there is no logic, I believe it would be userkey in username.
  • Even for .csv file UI upload, you don't see an option to generate username (only systemusername and email is available), but it's by default Saviynt checks 'Add Register User Rule' rule if username is blank.

 

If you like my solution, please hit Kudos!

Hi @PremMahadikar , 

Tried the query given above, and it did create the users this time but with some random numbers and no systemusername is generated. 

TheSaviyntBoy_0-1715660063712.pngTheSaviyntBoy_1-1715660091018.png

 

Did you selected required options during import ? Share logs


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Yes, I missed that option, the query is working fine now. 

Thank you.