Skip to main content
luisr0004
May 9, 2022
Solved

if() function

  • May 9, 2022
  • 10 replies
  • 0 views

Could someone explain why the following code work without compiler errors?

if(
    isnull(ri!user),
    "",
    isusernametaken(ri!user),
    user(ri!user, "firstName") & " " & user(ri!user, "lastName"),
    joinarray(split(ri!user, "."), " ")
)

I expect some kind of evaluation error, but it works just as the three lines starting on "isusernametaken" were an embedded if.

I saw that in one of the Appian courses and I'm wondering if it is some undocumented feature of the if function.

Thank you

    Best answer by davel001150

    if() has hidden else if functionality in it.  What's documented is:

    if(

    condition

    return if true,

    return if false

    )

    What you can do with it:

    if(

    condition1,

    return if condition1 true

    condition2 if condition1 false {else if}

    return if condition2 true

    return if condition2 false

    )

    Or you can do it with 7, 9, 11, 13.  Every odd input is another conditional until the very last one, what returns if they're ALL false.

    It's way less keypresses, but gets dramatically unreadable.

    10 replies

    richardm900458
    May 9, 2022

    if() has 3 parameter

    condition and true, false statement
    https://docs.appian.com/suite/help/22.1/fnc_logical_if.html


    if you like to use more
    check a!match()
    https://docs.appian.com/suite/help/22.1/fnc_logical_match.html

    -> this is just a kind of mistake in the appian course. at least unproper use. 

    luisr0004
    luisr0004Author
    May 9, 2022

    Thank you Richard, but why it does not trigger an error or warning in rule designer? 

    richardm900458
    May 9, 2022

    Lets say, as its not completely wrong in the sense that the rule is not technically breaking there is no error message.
    -> [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05] as far as i remember you reported that issue already? 

    davel001150
    May 9, 2022

    if() has hidden else if functionality in it.  What's documented is:

    if(

    condition

    return if true,

    return if false

    )

    What you can do with it:

    if(

    condition1,

    return if condition1 true

    condition2 if condition1 false {else if}

    return if condition2 true

    return if condition2 false

    )

    Or you can do it with 7, 9, 11, 13.  Every odd input is another conditional until the very last one, what returns if they're ALL false.

    It's way less keypresses, but gets dramatically unreadable.

    davel001150
    May 9, 2022

    As others have posted, a!match is basically the same thing in readable format.

    mikes0011
    Brainy
    May 9, 2022

    I am enjoying a!match.  Even now I have a special app package wherein i'm tracking down all the sloppy uses of "choose()" in my system and swapping them out.

    May 10, 2022

    I discovered the same last year, I sent email to Appian to ask if its right way to use it. They suggested not to use this functionality and use multiple if statements. Now we have a!match() function for the same functionality.