01/12/2023 01:00 PM
Hi,
I trying to do a case when statement in the username generation logic. Under the 'Add Register User Rule'.
It does not seem to be working. Even in the documentation it has case when examples for system username or email but not for username. Is this possible?
If not, does anyone have a different approach?
I tried setting username equal to system username and putting the logic needed in system username rule but that did not work either.
Thanks!
01/12/2023 01:04 PM
use if condition
https://www.w3schools.com/sql/func_mysql_if.asp
01/13/2023 06:38 AM
Thank you!
Do you have a sample of successful working statement? when I try something simple like 'IF (users.middlename is not null, users.firstname, users.lastname)'
it returns username as the full statement so username is being set to 'IFmiddlenameisnotnullJonnyTester'
01/13/2023 07:43 AM
What is the behaviour with case when statement?
can you share you sample case when statement that didn't work?
01/13/2023 08:29 AM
we have tried a few different things, I pasted two below. The first one gives the same behavior of making username the entire statement 'case whencustomproperty40=Employeethenfirstname else lastname end'. The second one just errors out.
Statement 1: case when users.customproperty40 = 'Employee' then users.firstname
else
users.lastname
end
Statement 2: concat(case when users.customproperty40 = 'Employee' then concat(substring('users.firstname',1,6)) else concat(substring('users.lastname',1,9))end)