
JonathanA.73987 (Customer) asked a question.
Hello,
I have a custom expression I am trying to attach to an Okta Group but when testing it with users outside the scope of this expression, they all "Match" the rule when they shouldn't.
Expression:
(user.WorkCountry=="Australia" OR user.WorkCountry=="Indonesia" OR user.WorkCountry=="Korea, Republic of" OR user.WorkCountry=="Malaysia" OR user.WorkCountry=="Philippines" OR user.WorkCountry=="Singapore" OR user.WorkCountry=="Thailand" OR user.WorkCountry=="Vietnam") AND String.stringContains(user.Job_Family,"Facilities") OR String.stringContains(user.Job_Family,"Community")

Hi @JonathanA.73987 (Customer) , Thank you for reaching out to the Okta Community!
Assuming that I understood your requirement correctly, and you need the user to be assigned only if they have any of the mentioned countries AND any of the jobs, I just ran a test with the custom expression you provided and it matches users that meet the condition of String.stringContains(user.Job_Family,"Community") regardless if they match any of the other conditions. Which I don't think is the desired outcome.
I then added an additional parentheses to the second part of the expression (after the AND) and it seems to be working. See example below:
(user.WorkCountry=="Australia" OR user.WorkCountry=="Indonesia" OR user.WorkCountry=="Korea, Republic of" OR user.WorkCountry=="Malaysia" OR user.WorkCountry=="Philippines" OR user.WorkCountry=="Singapore" OR user.WorkCountry=="Thailand" OR user.WorkCountry=="Vietnam") AND (String.stringContains(user.Job_Family,"Facilities") OR String.stringContains(user.Job_Family,"Community"))
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!
--------------------------------
Community members help others by clicking Like or Select as Best on responses. Try it today.