<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
0D51Y000081noZESAYOkta Classic EngineUniversal DirectoryAnswered2024-04-15T09:21:43.000Z2020-03-11T19:50:48.000Z2020-03-19T23:34:29.000Z

ulazx (ulazx) asked a question.

Expression to not include office location

I am trying to write an expression to say if your attribute is not one of these you will get put into a local okta group. I need a little help with this.

 

Example:

 

String.stringContains(user.physicalDeliveryOfficeName!=="HS - State1 - YourCity1") OR String.stringContains(user.physicalDeliveryOfficeName!=="HS - State2 - YorCity1") OR String.stringContains(user.physicalDeliveryOfficeName!=="HS - State3 - YourCity3") OR String.stringContains(user.physicalDeliveryOfficeName!=="HS - State4 - YourCity4")


  • GabrielL.85945 (Customer)

    Is it the case you want to check if the attribute does not contain any of those values? Or are you wanting to simply check if it is not equal to those values?

     

    If it's the ladder (not equal), I think you may be over-complicating things a bit with that function, the syntax of that function is not correct, and I think you might want to be using an AND instead of an OR. Have you just tried something more like this:

     

    user.physicalDeliveryOfficeName != "HS - State1 - YourCity1" AND user.physicalDeliveryOfficeName != "HS - State2 - YourCity2" AND user.physicalDeliveryOfficeName != "HS - State3 - YourCity3" AND user.physicalDeliveryOfficeName != "HS - State4 - YourCity4"

     

    The syntax for the String.stringContains() function can be found in the documentation below where they show examples:

    https://developer.okta.com/docs/reference/okta-expression-language/#string-functions

     

    If you are just checking if it's not equal to the value, then as you can see, you really don't need to use that function anyway.

     

    The reason you'll probably want an AND instead of an OR is because combining the OR with a bunch of != will basically make every evaluation resolve to true. Think of the logic this way: If you are NOT Jane OR if you are NOT John, you may have a sticker. Let's say you meet Fred, well he's not Jane and he's not John, so he'll get a sticker. But what about Jane? Well, "if you are NOT Jane" evaluates to false, so maybe Jane would NOT get a sticker. But wait! The next expression "if you are NOT John" resolves to true. After all, Jane is not John, correct? So Jane does get a sticker! And it's because when you use an OR, only one of the two conditions must evaluate to true.

     

    Here's the documentation on that:

    https://developer.okta.com/docs/reference/okta-expression-language/#conditional-expressions

    Expand Post
  • ulazx (ulazx)

    Thanks Gabriel.. so what i am trying to do is determine based on the users profile if they are in one of those cities or not, if it they are not in on of those specific cities they will be added to a specific okta group called RemoteWorkers

  • ulazx (ulazx)

    So after some looking at this this is what really needs to be figured out is:

     

    user.physicalDeliveryOfficeName != "HS - NY - Brookyln" AND user.physicalDeliveryOfficeName != "HS - FL - Miami" AND user.physicalDeliveryOfficeName != "HS - RI - Providence" AND user.physicalDeliveryOfficeName != "HS - OH - Cleveland"

     

    but also if someone has HS - * in their office location populate a group called RemoteWorkers

     

    HS - * equals any other location besides the one in the statement. For example: HS - TN - Nashville or HS - Offshore

    Expand Post
This question is closed.
Loading
Expression to not include office location