<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

Common Use Cases for the Elvis Operator in Okta Expression Language

Okta Classic Engine
Okta Identity Engine
Lifecycle Management

Overview

Okta supports the Elvis operator (?:) for Okta Expression Language (OEL) configuration. Administrators can utilize this operator to provide a default fallback value when an expression evaluates to a null or empty string.

Applies To

  • Okta Identity Engine (OIE)
  • Okta Classic Engine
  • Okta Expression Language (OEL)
  • User Lifecycle Management

Solution

What Is the Elvis Operator in Okta Expression Language?

Okta explicitly defines the Elvis operator (?:) as a binary operator that provides a default fallback value if an expression evaluates to null or an empty string ("").

 

The Elvis Operator Functions as an Alternative to Traditional Conditional Expressions

Administrators can create OEL syntax with the Elvis operator as an alternative to traditional conditional expressions.

 

How Does Okta Evaluate the Elvis Operator?

Administrators can compare the Elvis operator syntax to a traditional conditional expression.

(user.customEmailString ?: user.email)

This expression functions identically to the following traditional conditional expression:

user.customEmailString != "" AND user.customEmailString != null ? user.customEmailString : user.email

Evaluate the Elvis operator syntax by observing how Okta checks for non-null values, returns the primary string if valid, or falls back to the secondary string.

  1. Okta checks if user.customEmailString contains a non-null, non-empty string value.
  2. If user.customEmailString exists and is not empty, Okta returns user.customEmailString.
  3. If user.customEmailString is either null or an empty string, Okta evaluates and returns user.email instead.

 

Related References

Loading
Common Use Cases for the Elvis Operator in Okta Expression Language | Okta Support