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
  • 1) Try this if your list will be small

    foreach(

    local!List,

    load(

    local!id: queryEntity.data.id {query on individual field},

    if(isnull(local!id),

    ##generatecode##,

    local!id

    )

    )

    ),

    2) If list is big, 

    load(

    local!queryList:##Query all the ids##

    foreach(

    local!list,

    load(

    local!code:displayvalue(fv!item.id,local!queryList.id,local!queryList.code,"")

    if(isnull(local!code),##generateCode##,local!code)

    )

    )


    3) Performance wise best way to do this using Cursor inside the stored procedure. 

Reply
  • 1) Try this if your list will be small

    foreach(

    local!List,

    load(

    local!id: queryEntity.data.id {query on individual field},

    if(isnull(local!id),

    ##generatecode##,

    local!id

    )

    )

    ),

    2) If list is big, 

    load(

    local!queryList:##Query all the ids##

    foreach(

    local!list,

    load(

    local!code:displayvalue(fv!item.id,local!queryList.id,local!queryList.code,"")

    if(isnull(local!code),##generateCode##,local!code)

    )

    )


    3) Performance wise best way to do this using Cursor inside the stored procedure. 

Children
No Data