<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
0D54z00009c1S25CAEOkta Classic EngineAdministrationAnswered2023-12-04T20:40:27.000Z2023-08-30T06:59:40.000Z2023-08-31T19:39:30.000Z

JeffreyT.73994 (Customer) asked a question.

Okta Query Language and relational operators between Array of Strings and Int

Preface: We have user objects with attributes in a string array. All values of the string array should be numbers that correlate to a business unit.

 

Example:

User ABC

BusinessUnits{"200","300"}

 

I need to create a rule to query for users who have business units >=100 and <=500. The issue im having is that the array Business units have string values and I need to use relational operators with Integers.

Is there a way to force type cast on the output of the Arrays.get(user.BusinessUnits,0) function to force that into an Integer and then run a relational operator? I've tried but keep getting errors.

 

I've also tried using using Convert.toInt(Arrays.get(user.BusinessUnits,0)) but also getting errors when using this as well. Any help would be greatly appreciated.

 

Thank you


  • Mihai N. (Okta, Inc.)

    Hi @JeffreyT.73994 (Customer)​ , Thank you for reaching out to the Okta Community!

     

    Assuming I've understood the use case correctly and you are referring to Group Rules here, I've set up a test rule with the following examples with the caveat that it really depends on the number of arrays you've got for your users. The expression could perhaps be extended but it's not really scalable for large numbers of arrays. 

     

    Using your example as a starting point I've created 2 users: 

     

    User business.unit1@domain.com

    with BusinessUnits (string array) attribute values of {"200","300"}

     

    AND

     

    User business.unit2@domain.com

    with BusinessUnits (string array) attribute values of {"600","700"}

     

     

    Then created the following Group Rule: 

     

    IF

     

    Arrays.get(user.BusinessUnits, 0) >= "100" && Arrays.get(user.BusinessUnits, 1) <= "500"

     

    THEN Assign to 

     

    "BusinessUnits" group.

     

     

     

    RESULT: The business.unit1 user is added to the group and business.unit2 user is NOT added to the group.  

     

     

     

    Screenshot of the group rule configuration:

    Pasted 

     

     

    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 Moderator Tip: Join a group today and connect with other Okta customers by region or product.

    Expand Post
  • JeffreyT.73994 (Customer)

    Hi Mihai,

     

    The issue here is the comparison of two strings. With your example it seems to work fine but if you were to create a new user with {"20","30"} as business codes this should fail all logic. But due to the comparison of string values, this will actually return true.

     

    Hoping you can validate - at least this is whats happening to me.

     

    Thanks,

    Jeff

    Expand Post
    • Mihai N. (Okta, Inc.)

      Yeah, you're right. Sorry I missed that 😞

      I went back and confirmed, then reviewed the Okta Expression Language docs and I can't see any way to make this work.

      Array and Convert functions are not supported in conditions and I assume the Array.contains function is too specific for the variables that you might want to use, right?

      Expand Post
  • JeffreyT.73994 (Customer)

    Hi Mihai,

     

    No worries. I totally appreciate the assist here. You are correct, since there are are a lot of values, Array.contains would just have too much logic in it. However, we don't really have another solution so this will have to do for now.

     

    Thank you again!

    Best,

    Jeff

    Expand Post
    • Mihai N. (Okta, Inc.)

      Not really my area of expertise, but you could check the Workflows discussion board if there's something there that could help with this use case.

This question is closed.
Loading
Okta Query Language and relational operators between Array of Strings and Int