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

How to limit user displayname characters to 20 characters in insert query of DB connector

harishyara
Regular Contributor
Regular Contributor

Hi Team, We have a use case - while creating/inserting a new record into mysql database (DB connector) I need to check if user's displayname is more than 20 characters then I need to insert max upto 20 characters only. Please help to provide DB insert query syntax to limit username characters to 20. 

7 REPLIES 7

rushikeshvartak
All-Star
All-Star

${user.displayname.substring(0, 20)}


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

NM
Honored Contributor II
Honored Contributor II

@harishyara ${if (user.displayname.length>20){user.displayname.substring(0, 20)} else {user.displayname}}

harishyara
Regular Contributor
Regular Contributor

Hello @NM - could you please help me on above condition using conditional operator  ?

${user.displayname ? user.displayname.substring(0, 20) : null}


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

NM
Honored Contributor II
Honored Contributor II

${(user.displayname.length>20)?user.displayname.substring(0, 20):user.displayname}

@harishyara 

harishyara
Regular Contributor
Regular Contributor

@NM - If I use above syntax getting this error: No such property: length for class: java.lang.String

${(user.displayname.length()>20)?user.displayname.substring(0, 20):user.displayname}

length is mysql

length() is java


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