Skip to main content
May 18, 2022
Question

If Statement show and hide

  • May 18, 2022
  • 3 replies
  • 0 views

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))

    3 replies

    May 18, 2022

    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
    )

    May 18, 2022

    oh sorry maybe I wasn't clear but this was for a email, does the same logic apply? 

    May 19, 2022

    Yes, It will work. Create an expression rule with this logic and call that rule in your email node.

    ex: 
    rule!returnName(
    name1: pv!name1,
    name2: pv!name2,
    name3: pv!name3
    )