
x3ko2 (x3ko2) asked a question.
I want to find all users containing @olddomain.com then replace all these with @newdomain.com. How do we write that in Okta expression language? Is the statement below correct?
String.stringContains(user.email, “@domain.com”) ? String.replace(user.email, “@newdomain.com)

Hi @loch8 (loch8) , Thank you for reaching out to the Okta Community!
The following should help you achieve what you are looking for.
Resource: https://developer.okta.com/docs/reference/okta-expression-language/#string-functions
> CONDITIONAL FUNCTIONS:
[Condition] ? [Value if TRUE] : [Value if FALSE]
> REQUIREMENT: find OLD_domain in user's email and replace with NEW_domain
Syntax according to documentation:
String.stringContains("This is a test", "test") ? String.replace("This is a test", "is", "at") : user.email
Example for this use case:
String.stringContains(user.email, "@oldDomain.com") ? String.replace(user.email, "@oldDomain.com","@newDomain.com") : user.email
⚠️ I recommend setting up a mock app to test this mapping before applying the changes in production.
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 it helps!