<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
0D54z00008dlzbBCAQOkta Classic EngineUniversal DirectoryAnswered2023-01-19T16:37:15.000Z2023-01-13T21:30:25.000Z2023-01-19T16:37:15.000Z

JonathanA.73987 (Customer) asked a question.

Okta Group Rule Custom Expression not filtering out using all conditions

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.

    Expand Post
    Selected as Best
  • 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.

    Expand Post
    Selected as Best
This question is closed.
Loading
Okta Group Rule Custom Expression not filtering out using all conditions