Why if() takes more arguments than 3?

I saw such a example code in APPIAN DEVELOPER course practice document. (Expressions: Transform Your Data, Build an Application: Step 4)

I couldn't understand why if() coukd take arguments more than 3. The usage of if() should be "if(condition, valueIfTrue, valueIfFalse)" according to official doc.

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

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    This has long been a trick we can sometimes use to avoid messy if() nesting - with the caveat that the functionality is semi-unsupported, and completely unsupported in the GUI interface editor (i found at one point that if you enter it into the code, it'll refuse to switch back to the GUI editor, for anyone who cares about using that at all).

    Fortunately now there's no longer any need to do this, since Appian introduced a!match() in 22.1, which handles a list of conditions in a way that recreates an "if, elseif, elseif, (...), else" statement with any number of parameters with no nesting needed.  In that case I think we can pretty much consider the multi-condition if() functionality deprecated (other than the fact that it isn't officially documented anyway), though I don't expect its back-end functionality will change anytime soon since that could break exisitng code.

    I agree though, I'm not sure why they included that undocumented functionality in any training documentation (but also I'm not super surprised).

Reply
  • 0
    Certified Lead Developer

    This has long been a trick we can sometimes use to avoid messy if() nesting - with the caveat that the functionality is semi-unsupported, and completely unsupported in the GUI interface editor (i found at one point that if you enter it into the code, it'll refuse to switch back to the GUI editor, for anyone who cares about using that at all).

    Fortunately now there's no longer any need to do this, since Appian introduced a!match() in 22.1, which handles a list of conditions in a way that recreates an "if, elseif, elseif, (...), else" statement with any number of parameters with no nesting needed.  In that case I think we can pretty much consider the multi-condition if() functionality deprecated (other than the fact that it isn't officially documented anyway), though I don't expect its back-end functionality will change anytime soon since that could break exisitng code.

    I agree though, I'm not sure why they included that undocumented functionality in any training documentation (but also I'm not super surprised).

Children
No Data