Is there a case statement /function in Appian . or an if ...else if in rules exp

Is there a case statement /function in Appian . or an if ...else if in rules expressions . Coding in terms of if , if ... is time consuming and code readability is bad .

OriginalPostID-219960

OriginalPostID-219960

  Discussion posts and replies are publicly visible

Parents
  • I would suggest a combination of fn!choose and fn!displayvalue to simulate a "switch" case in Appian. fn!choose is like switch case - but with one caveat - the "key" should be a number - it does not allow text values or float values. So, you can use fn!displayvalue with fn!choose when the value which decides which branch to takes is not a number.

    Example Snippet:
    load(

    /*local!statusCode will be 1 or 2 or -1
    1 - Approved
    2 - Rejected
    -1 - Some invalid value*/
    local!statusCode: fn!displayvalue(
    ri!status,
    {"Approved", "Rejected"},
    {1,2},
    -1
    ),

    fn!choose(
    local!statusCode,

    {
    /*code for choice1 */
    },

    {
    /*code for choice2 */
    }
    )
    )
Reply
  • I would suggest a combination of fn!choose and fn!displayvalue to simulate a "switch" case in Appian. fn!choose is like switch case - but with one caveat - the "key" should be a number - it does not allow text values or float values. So, you can use fn!displayvalue with fn!choose when the value which decides which branch to takes is not a number.

    Example Snippet:
    load(

    /*local!statusCode will be 1 or 2 or -1
    1 - Approved
    2 - Rejected
    -1 - Some invalid value*/
    local!statusCode: fn!displayvalue(
    ri!status,
    {"Approved", "Rejected"},
    {1,2},
    -1
    ),

    fn!choose(
    local!statusCode,

    {
    /*code for choice1 */
    },

    {
    /*code for choice2 */
    }
    )
    )
Children
No Data