
7jv04 (7jv04) asked a question.
Happy Friday Jr all (aka Thursday)! I'm solving for an issue and thought it might be a good one to share with the community.
I'm trying to figure out how to get around an error encountered while testing user profile import/creation in Okta Preview. When a user has multiple surnames (firstname, lastname, lastname, etc) it seems to be breaking the logic in the expression I created to construct the company email address in Okta. Error: "email Does not match the required pattern."
Users get an email address to be Firstname(or preferred first name if they have one)+Lastname@domain.com.
The expression works perfectly for user with a singular first name and singular last name:
Current email expression:
String.toLowerCase(appuser.PreferredFirstName == "" ? appuser.FirstName + appuser.LastName + '@domain.com' : appuser.PreferredFirstName + appuser.LastName + '@domain.com')
I'm trying to figure out how to select the first surname.
This is close, but split is not a valid property in the Okta expression language apparently and I'm struggling to find the right syntax:
String.toLowerCase(appuser.PreferredFirstName == "" ? appuser.FirstName + appuser.LastName.split(" ")[0] + '@domain.com' : appuser.PreferredFirstName + appuser.LastName.split(" ")[0] + '@domain.com')
This is also close but still invalid syntax:
String.toLowerCase(appuser.PreferredFirstName == "" ? appuser.FirstName + appuser.LastName.substringBefore(" ") + '@domain.com' : appuser.PreferredFirstName + appuser.LastName.substringBefore(" ") + '@domain.com')
I'm curious if others have encountered something similar, and how it was solved for.

@7jv04 (7jv04) -- I don't have a solution for you. However, I recommend providing an "example" so it is better understood what you are trying to achieve. It is pretty odd to have two (attributes) with the same name that have different values. To the best of my understanding they would need to have two different unique variable names as these are effectively the "unique key" on a profile. If you can provide a more detailed description on the scenario with a mocked up user that demonstrates the problem && the desired outcome I suspect someone can help.
for example do you mean something along the lines of:
firstName = Tom
lastName = jones white
or
lastName= jones-white
Having a better understanding of the exact criteria is what I am talking about.