Skip to main content
hema.mathivathanan
November 16, 2023
Solved

expression rule

  • November 16, 2023
  • 4 replies
  • 0 views

Hi, I have a expression rule which has the result : Name - Company - Phoneno. 

I concatenated with "-" when I get the above 3 values.
In some cases, the name can be blank / company / phone no. If the name is blank, my result is like  -company-phoneno. 
If the phoneno is blank, then it's name-company-

How to remove the - if the value is not present ?

    Best answer by mathieud0001

    a!localVariables(
      local!part1: "",
      local!part2: "part2",
      local!part3: "",
      local!stringsToConcat: {
        local!part1,
        local!part2,
        local!part3
      },
      joinarray(local!stringsToConcat, " - ")
    )

    4 replies

    mathieud0001
    November 16, 2023

    a!localVariables(
      local!part1: "",
      local!part2: "part2",
      local!part3: "",
      local!stringsToConcat: {
        local!part1,
        local!part2,
        local!part3
      },
      joinarray(local!stringsToConcat, " - ")
    )

    hema.mathivathanan
    November 16, 2023

    a!localVariables(
    local!part1: "",
    local!part2: "part2",
    local!part3: "",
    concat(
    local!part1,
    if(a!isNotNullOrEmpty(local!part2), concat(" - ", local!part2), ""),
    if(a!isNotNullOrEmpty(local!part3), concat(" - ", local!part3), "")
    )
    ), In this case it will return -part2

    mathieud0001
    November 16, 2023

    Edited my response with something a little more robust.