<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
System Status
Announcements
Announcements
Search
Search
Select Language
0D5WR00002WkkuI0AROkta Classic EngineAdministrationAnswered2026-11-27T17:32:07.000Z2026-11-27T17:27:28.000Z2026-11-27T17:32:07.000Z
  • Mihai N. (Okta, Inc.)

    Ten of the most practical Okta Expression Language (OEL) expressions used across Profile Mappings, Group Rules, and SAML/OIDC claims:

     

    1.Extract Username Prefix from Email (Profile Mapping / App Username)

     

    String.substringBefore(user.email, "@")

    Strips the domain from jane.doe@company.com to return jane.doe for legacy apps or SAMAccountName mappings.

     

    2.Null-Safe Preferred Name Fallback (Profile Mapping / SAML Claims)

     

    (user.nickName != null && user.nickName != "") ? user.nickName : user.firstName

    Uses a ternary check to send a user's preferred name when populated and fall back to their legal first name when blank or null.

     

    3.Generate Clean Lowercase first.last Emails (Inbound HR Mapping)

     

    String.toLowerCase(String.replace(user.firstName, " ", "") + "." + String.replace(user.lastName, " ", "") + "@company.com")

    Removes spaces from multi-word names and normalizes casing during HR-as-a-Master imports.

     

    4.Strip Formatting from Phone Numbers (Profile Mapping / SMS MFA)

     

    "+1" + String.replace(String.replace(String.replace(String.replace(user.mobilePhone, "-", ""), " ", ""), "(", ""), ")", "")

    Converts (555) 123-4567 into +15551234567. Nested String.replace() calls are required because OEL performs literal string replacements rather than regex.

     

    5.Swap Email Domains per Application (Profile Mapping)

     

    String.substringBefore(user.email, "@") + "@newdomain.com"

    Rewrites the email domain for a specific downstream app during rebrands or mergers without altering the user's primary Okta login.

     

    6.Filter Groups by Prefix for SAML or OIDC Tokens (SSO Claims)

     

    Groups.startsWith("active_directory", "APP_AWS_", 100)

    Sends only Active Directory groups matching a specific prefix (up to the specified limit) to prevent token bloat. Replace "active_directory" with "OKTA" to target Okta-mastered groups.

     

    7.Exclude Multiple Email Domains (Group Rules)

     

    !(String.stringContains(String.toLowerCase(user.email), "@partner1.com") OR String.stringContains(String.toLowerCase(user.email), "@partner2.com"))

    Combines negated String.stringContains checks with OR to separate internal staff from external contractors or partners. Wrapping user.email in String.toLowerCase() avoids mismatches since OEL string comparisons are case-sensitive.

     

    8.Scope Group Rules to Active Users Only (Group Rules)

     

    user.department == "Engineering" && user.getInternalProperty("status") == "ACTIVE"

    Combines standard profile attributes with user.getInternalProperty("status") so suspended, staged, or locked-out users are excluded from dynamic app groups.

     

    9.Match a Value Inside a String Array Attribute (Group Rules / Policies)

     

    user.customRoles != null && Arrays.contains(user.customRoles, "Admin")

    Checks multi-valued Universal Directory attributes while preventing null errors. Note that Arrays.contains performs an exact, case-sensitive full-element match and will not match substrings.

     

    10.Pull a Manager's Attribute from a Linked Directory (SAML / SCIM / Profile Mapping)

     

    getManagerUser("active_directory").email

    Resolves the user's linked manager object directly from Active Directory (or another configured source) to pass the manager's email or login to downstream apps like ServiceNow or Jira.

    Tip: OEL is strictly case-sensitive for both attribute names and string values—always test expressions against real profiles with the Preview button before activating a Group Rule or mapping in production.

     

    For more information regarding Okta Expression Language please visit: https://developer.okta.com/docs/reference/okta-expression-language/

     

    Expand Post
    Selected as Best
  • Mihai N. (Okta, Inc.)

    Ten of the most practical Okta Expression Language (OEL) expressions used across Profile Mappings, Group Rules, and SAML/OIDC claims:

     

    1.Extract Username Prefix from Email (Profile Mapping / App Username)

     

    String.substringBefore(user.email, "@")

    Strips the domain from jane.doe@company.com to return jane.doe for legacy apps or SAMAccountName mappings.

     

    2.Null-Safe Preferred Name Fallback (Profile Mapping / SAML Claims)

     

    (user.nickName != null && user.nickName != "") ? user.nickName : user.firstName

    Uses a ternary check to send a user's preferred name when populated and fall back to their legal first name when blank or null.

     

    3.Generate Clean Lowercase first.last Emails (Inbound HR Mapping)

     

    String.toLowerCase(String.replace(user.firstName, " ", "") + "." + String.replace(user.lastName, " ", "") + "@company.com")

    Removes spaces from multi-word names and normalizes casing during HR-as-a-Master imports.

     

    4.Strip Formatting from Phone Numbers (Profile Mapping / SMS MFA)

     

    "+1" + String.replace(String.replace(String.replace(String.replace(user.mobilePhone, "-", ""), " ", ""), "(", ""), ")", "")

    Converts (555) 123-4567 into +15551234567. Nested String.replace() calls are required because OEL performs literal string replacements rather than regex.

     

    5.Swap Email Domains per Application (Profile Mapping)

     

    String.substringBefore(user.email, "@") + "@newdomain.com"

    Rewrites the email domain for a specific downstream app during rebrands or mergers without altering the user's primary Okta login.

     

    6.Filter Groups by Prefix for SAML or OIDC Tokens (SSO Claims)

     

    Groups.startsWith("active_directory", "APP_AWS_", 100)

    Sends only Active Directory groups matching a specific prefix (up to the specified limit) to prevent token bloat. Replace "active_directory" with "OKTA" to target Okta-mastered groups.

     

    7.Exclude Multiple Email Domains (Group Rules)

     

    !(String.stringContains(String.toLowerCase(user.email), "@partner1.com") OR String.stringContains(String.toLowerCase(user.email), "@partner2.com"))

    Combines negated String.stringContains checks with OR to separate internal staff from external contractors or partners. Wrapping user.email in String.toLowerCase() avoids mismatches since OEL string comparisons are case-sensitive.

     

    8.Scope Group Rules to Active Users Only (Group Rules)

     

    user.department == "Engineering" && user.getInternalProperty("status") == "ACTIVE"

    Combines standard profile attributes with user.getInternalProperty("status") so suspended, staged, or locked-out users are excluded from dynamic app groups.

     

    9.Match a Value Inside a String Array Attribute (Group Rules / Policies)

     

    user.customRoles != null && Arrays.contains(user.customRoles, "Admin")

    Checks multi-valued Universal Directory attributes while preventing null errors. Note that Arrays.contains performs an exact, case-sensitive full-element match and will not match substrings.

     

    10.Pull a Manager's Attribute from a Linked Directory (SAML / SCIM / Profile Mapping)

     

    getManagerUser("active_directory").email

    Resolves the user's linked manager object directly from Active Directory (or another configured source) to pass the manager's email or login to downstream apps like ServiceNow or Jira.

    Tip: OEL is strictly case-sensitive for both attribute names and string values—always test expressions against real profiles with the Preview button before activating a Group Rule or mapping in production.

     

    For more information regarding Okta Expression Language please visit: https://developer.okta.com/docs/reference/okta-expression-language/

     

    Expand Post
    Selected as Best

Loading
Okta Expression Language (OEL)
Okta Support Agent (Beta)

Terms of Service

Hello! I'm the Okta Support Agent (Beta), your go-to resource for questions about Okta products. Please remember for your security and privacy, do not share any Personally Identifiable Information (PII) such as passwords, IP addresses, or other details with me.

Okta Privacy Policy and Terms of Service apply