<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
Understanding Okta Expression Language: Flattening Filtered Groups and Replacing String Segments
Okta Classic Engine
Okta Identity Engine
Lifecycle Management
Overview

This article provides an in-depth explanation of a particular Okta Expression Language expression that retrieves user group information, modifies the group names, and returns the result as a flat array. The Okta Expression Language is a versatile tool that enables administrators to manipulate and handle user and group data effectively.

Applies To
  • Okta Expression Language (OEL)
Solution

There may be a need to retrieve specific group data for a user, manipulate these data (like removing certain substrings from the group names), and ensure the output is a flat array (i.e., it has only one level). Okta Expression Language provides a way to achieve these outcomes.

The expression Arrays.flatten(String.replace(getFilteredGroups({"Group1_ID","Group2_ID"}, "group.name", 40), "SSO-", "") ) achieves the following:
 

  1. getFilteredGroups({"Group1_ID","Group2_ID"}, "group.name", 40) retrieves the names of the first 40 groups that a user is a member of, among the specified groups ("Group1_ID" and "Group2_ID").
     

  2. String.replace(getFilteredGroups({"Group1_ID","Group2_ID"}, "group.name", 40), "SSO-", "") takes the results of the getFilteredGroups function and removes any occurrence of SSO- in the group names.
     

  3. Arrays.flatten(String.replace(getFilteredGroups({"Group1_ID","Group2_ID"}, "group.name", 40), "SSO-", "") ) ensures the output is a flat array, useful in cases where the String.replace function results in an array of arrays.


Related References

Loading
Understanding Okta Expression Language: Flattening Filtered Groups and Replacing String Segments