This article explains how to populate the 'Alias' field in App User Profile mappings using the first four characters of the user's secondary email. Instead of using first and last names, we'll use the part of the secondary email before and after the dot ('.'). This approach is particularly useful when dealing with names that contain special characters, such as apostrophes.
- Okta Admins
- Salesforce Users
- User Profile Mapping
- Navigate to the Profile Editor in Okta.
- Select the app user profile for the app integration.
- Go to Mappings > Okta User to App User.
- Look for the field on the left that points to Alias.
Now, enter the following Okta Expression Language expression:
String.substring(user.secondEmail, 0,4) + String.substring(String.substringAfter(user.secondEmail,'.'), 0,4)
This expression works by taking the first four characters from the 'secondEmail' attribute of the user, then appending the first four characters after the dot ('.') in the 'secondEmail' attribute.
Here's a quick background on the Okta Expression Language used in the solution:
Okta Expression Language allows for various functions to manipulate attributes or properties to generate a desired output. These functions can be combined and nested within a single expression. In this case, we use two string functions:
-
String.substring(String input, int startIndex, int endIndex): Returns a new string that is a substring of the 'input'. The substring begins at the specified 'startIndex' and extends to the character at index 'endIndex - 1'.
-
String.substringAfter(String input, String searchString): Returns a new string that is a substring of the 'input' that appears after the first occurrence of the 'searchString'. If no such 'searchString' is found, it returns an empty string.
These functions, among others, provide a powerful way to manipulate string data within Okta expressions.
