Okta Expression Language - Join strings based on multiple group memberships? Skip to main content
https://support.okta.com/help/answers?id=9062a000000bm4lqaq&refurl=http%3a%2f%2fsupport.okta.com%2fhelp%2fanswers
How satisfied are you with the Okta Help Center?
Thank you for your feedback!
How satisfied are you with the Okta Help Center?
1
2
3
4
5
Very Dissatisfied
Very satisfied
Enter content less than 200 characters.
Ask Search:
Owen FullerOwen Fuller 

Okta Expression Language - Join strings based on multiple group memberships?

Is there a way to to set the value of a variable in profile mapping as a combination of strings based on membership in various groups?

For example, we have a string called Build_Office.  Values can be blank, one, or multiple semicolon-dilimted office locations in a given list (e.g. Iowa, Nebraska, etc.).  I would like to set this variable based on group membership.  For example if the user belongs to the group OktaSalesforceTestBOIowa the string should get a value of Iowa.  However, if the user is also a member of OktaSalesforceTestBONebraska, then the string should get set to a value of Iowa;Nebraska instead, and so on.

I can successfully set the value for a single group with this expression, but I'm having trouble figuring out how to conditionally join strings for a number of groups.

isMemberOfGroupName("OktaSalesforceTestBOIowa") ? 'Iowa' : ''
Best Answer chosen by Owen Fuller
Owen FullerOwen Fuller
Well, I actually found an answer to my own question after experimenting for awhile.  I'll share it here for anyone else who may have a similar need (or for suggestions for a better way to do it).
String.join(";", isMemberOfGroupName("OktaSalesforceTestBOIowa") ? 'Iowa' : '',  isMemberOfGroupName("OktaSalesforceTestBONebraska") ? 'Nebraska' : '')

 

All Answers

Owen FullerOwen Fuller
Well, I actually found an answer to my own question after experimenting for awhile.  I'll share it here for anyone else who may have a similar need (or for suggestions for a better way to do it).
String.join(";", isMemberOfGroupName("OktaSalesforceTestBOIowa") ? 'Iowa' : '',  isMemberOfGroupName("OktaSalesforceTestBONebraska") ? 'Nebraska' : '')

 
This was selected as the best answer
Nidhin C KNidhin C K
Thanks for sharing!