If Statement show and hide

Goal: name1, name2, name3 (show and hide comas in between and names if they are selected) 

Default is N/A if no names are selected

What I have tried: 

if(isnull({pv!process.name1,pv!process.name2,pv!process.name3}), "N/A","") & if(isnull(pv!process.name1), "",", "& pv!process.name1) & if(isnull(pv!process.name2), "", ", "&pv!process.name2) & if(isnull(pv!process.name3), "", ", "&pv!process.name3))

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi,

    You can use the following logic.

    a!localVariables(
      local!name: if(
        all(
          fn!isnull, 
          {
            ri!name1,
            ri!name2,
            ri!name3
          }
        ), 
        "N/A",
        concat(
          if(
            a!isNullOrEmpty(ri!name1),
            "",
            ri!name1
          ),
          if(
            a!isNullOrEmpty(ri!name2),
            "",
            if(
              a!isNullOrEmpty(ri!name1),
              ri!name2,
              {
                ", ",
                ri!name2
              }
            )
          ),
          if(
            a!isNullOrEmpty(ri!name3),
            "",
            if(
              and(
                a!isNullOrEmpty(ri!name1),
                a!isNullOrEmpty(ri!name2)
              ),
              ri!name3,
              {
                ", ",
                ri!name3
              }
            )
          )
        )
      ),
      local!name
    )

Reply
  • 0
    Certified Lead Developer

    Hi,

    You can use the following logic.

    a!localVariables(
      local!name: if(
        all(
          fn!isnull, 
          {
            ri!name1,
            ri!name2,
            ri!name3
          }
        ), 
        "N/A",
        concat(
          if(
            a!isNullOrEmpty(ri!name1),
            "",
            ri!name1
          ),
          if(
            a!isNullOrEmpty(ri!name2),
            "",
            if(
              a!isNullOrEmpty(ri!name1),
              ri!name2,
              {
                ", ",
                ri!name2
              }
            )
          ),
          if(
            a!isNullOrEmpty(ri!name3),
            "",
            if(
              and(
                a!isNullOrEmpty(ri!name1),
                a!isNullOrEmpty(ri!name2)
              ),
              ri!name3,
              {
                ", ",
                ri!name3
              }
            )
          )
        )
      ),
      local!name
    )

Children