How do we check username availability in a recursive and incremental basis in an Expression Rule?

Hi All,

 

I am trying to achieve the below in an Appian expression rule;

Expression Rule will have two inputs, firstName (Text), lastName (Text). It prepares a username with the logic as below.

concat(
  lower(
    split(
      ri!firstName,
      " "
    )
  ),
  ".",
  lower(
    split(
      ri!lastName,
      " "
    )
  )
)

But what I need is if the isusernametaken of that result is true, I have to append 1 and return the username.

Even if that is unavailable, I have to append 2 and return the username.

This should continue until a username is returned which is available.

Example:-

Inputs:-

firstName -> John Rod

lastName -> Williams 

username -> johnrod.williams

If the above username is not available, it should return johnrod.williams1. Even if it is not available, return johnrod.williams2 

How can we achieve this in an Expression Rule?

 

Thank you,

Arun

  Discussion posts and replies are publicly visible

Parents
  • One thing I always remind people of with isusernametaken is that it is case sensitive, e.g. isusernametaken("UserOne") will return false, even if there is a user with name "userone". But, if you try to create a user with that name, it will fail, so isusernametaken is not a reliable way of determining if a username is actually taken unless you know for sure all your usernames are in the same case.
Reply
  • One thing I always remind people of with isusernametaken is that it is case sensitive, e.g. isusernametaken("UserOne") will return false, even if there is a user with name "userone". But, if you try to create a user with that name, it will fail, so isusernametaken is not a reliable way of determining if a username is actually taken unless you know for sure all your usernames are in the same case.
Children