<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
0D51Y00005zS8vsSACOkta Classic EngineAdministrationAnswered2024-05-02T16:25:29.000Z2019-02-21T02:32:58.000Z2019-02-22T11:52:32.000Z
Help with Expression Language

Hi Experts,

I have AD mastered users in Okta. I need to write rule in Okta that should assign users to group only if their login id has digits. I went through https://developer.okta.com/reference/okta_expression_language/*string-functions but couldn't find relevant function that solves my purpose.

 

For example:

 

Login IDs are 123456 and C12345.

 

If Login ID is 123456 then assign user to group otherwise ignore group assignment.

 

I tried with String.startsWith(user.login,"C") - but this rule doesnt apply for users who has login id as number. So i am not able to assign to group.

 

How can I write string function that checks if login id has only numbers and then assign to group?

 

Any suggestions?

Thanks


  • VanH.30758 (Lytx, Inc.)

    Hmm.. Maybe a little bit more information could help. Does the first character, if it is a letter, always start with the letter C? is it random letters? Does it not always start with a letter?

     

    What if you did a "NOT" check?

     

    So for example if the userlogins always start with the capital letter "C" (or not at all)...

     

    !String.startsWith(user.login,"C") - expression is asking if the first character does NOT start with "C".

     

    Expand Post
    Selected as Best
  • VanH.30758 (Lytx, Inc.)

    Hmm.. Maybe a little bit more information could help. Does the first character, if it is a letter, always start with the letter C? is it random letters? Does it not always start with a letter?

     

    What if you did a "NOT" check?

     

    So for example if the userlogins always start with the capital letter "C" (or not at all)...

     

    !String.startsWith(user.login,"C") - expression is asking if the first character does NOT start with "C".

     

    Expand Post
    Selected as Best
  • KetanS.89652 (Customer)

    There must be other sane way of doing it but following will get the job done too. Following assumes that login length is 5 character. If it is more or less, adjust the number of zeros below.

     

    Following rules replaces all numeric digits 1-9 in login with 0 so if login is ONLY consists of digits then finally you should get all Zeros 🙂

     

    String.replace(String.replace(String.replace(String.replace(String.replace(String.replace(String.replace(String.replace( String.replace(String.substringBefore(user.login,"@"),"1","0"), "2","0"),"3","0"),"4","0"),"5","0"),"6","0"),"7","0"),"8","0"),"9","0")=="00000"

    Expand Post
This question is closed.
Loading
Help with Expression Language