While Loop

Hello everyone,

I need to do a expression rule which will return a unique code.

So my expression will need to generate a code (done already), verify if exists already in the database, if yes, the expression will need to generate another code, until it does not exists in the database.

I checked loop functions in Appian and does not find the While loop function, but rather functions with known iteration like "forEach", "apply".

Thank you in advance.

Nanbei

  Discussion posts and replies are publicly visible

Parents
  • Hello Nanbei,

    First and foremost, it is not recommended to run the query entity(or any kind of DB calls) inside a loop. You can create a stored procedure and move the same logic to the database side. So that the performance will not be affected and you can use the while loop in the Stored Procedure.

    Or if the code is just a unique number, then you can just make of use of the auto-generated primary key column.

Reply
  • Hello Nanbei,

    First and foremost, it is not recommended to run the query entity(or any kind of DB calls) inside a loop. You can create a stored procedure and move the same logic to the database side. So that the performance will not be affected and you can use the while loop in the Stored Procedure.

    Or if the code is just a unique number, then you can just make of use of the auto-generated primary key column.

Children