
NareshB.09653 (Customer) asked a question.
I have groups created in okta and added users to the groups.
group name is like company_id_name, i am trying to tranform this and return the custom claim of a user as [{"name":"companyname", "id":"companyid"} ].
I am using expression language to convert the groups in this format.
- added a simple custom claim and value type as Group and filter as start with "company", this returns fine. this works to make sure user is part of the groups.
- Now i want to add expression to transform the claim fo json format. I started with basic expression like Groups.Contains("company_") and Groups.startsWith("company"), nothin is being returned.
- I have tried more complex expression like below but did not work. Nothing worked hence tried the basic expression mentioned in step2.
- I don't find any error/ is there a place to check logs on what is happening with this claim / how is this getting calculated.
-------------------------
String.replaceAll(
Groups.contains("company_", "group.name")[0],
"company_([^_]+)_([^_]+)_([^_]+)",
"{\"id\":\"$1\",\"name\":\"$2\",\"isOrg\":$3}"
)
---------------------------

Hi @NareshB.09653 (Customer) , Thank you for reaching out to the Okta Community!
The Okta Expression Language docs mention that for Group.contains/startsWith you will need to reference the app_type/app_instance_id, pattern, limit - Groups.contains(app_type/app_instance_id, pattern, limit), so you should try using parts of what is mentioned in this article then build on that.
Groups.startsWith("OKTA","company_",100)
You could try your luck by opening a case with the Support Team, so they can review your particular configuration and variables to see if they can help you set up an expression for this use case, but please note that custom work typically falls outside of support scope.
If my answer helped, remember to mark it as best to increase its visibility for other members of the Okta Community who might have the same questions as you.
Hope my answer helps!
--
Help others in the community by liking or hitting Select as Best if this response helped you.
Collect them all. Learn a new skill and earn a new Okta Learning badge.