Skip to main content
May 17, 2022
Question

If statement and logic

  • May 17, 2022
  • 2 replies
  • 0 views

Goal: John Joe(12/2) 

Breakdown:
Name: John.Joe (User picker) 
Birthday: (date&time)

If no name is selected then present "N/A"

What I have tried: 

=if(isnull(pv!processvariable.name), "N/A", user(pv!processvariable.name,"firstName")& " " & user(pv!processVriable.name,"lastName") & "(" pv!processVariable.birthday &" )" )

Problem: Issue with If statement 

    2 replies

    agamb0001
    May 17, 2022

    if(isnull(pv!processvariable.name), "N/A", user(pv!processvariable.name,"firstName")& " " & user(pv!processvariable.name,"lastName") & "(" & pv!processvariable.birthday &" )" )

    you seems to be missing an "&" (highlighted in green)

    assuming you have a CDT type process variable named: processvariable

    please correct the typo (corrected in amber)

    stewart.burchell
    May 17, 2022

    Personally I find it more readable/codable to use the concat() function to avoid this kind of syntax error:

    = if(
      isnull(pv!processvariable.name),
      "N/A",
      fn!concat(
        user(pv!processvariable.name, "firstName"),
        " ",
        user(pv!processVriable.name, "lastName"),
        "(",
        pv!processVariable.birthday,
        " )"
      )
    )

    Separately, I notice you must be doing this in a Script Task in your process model. It's best practice to encapsulate code in an expression rule where it can be tested independently of the process itself. If you'd taken this route you would have found the error for yourself when constructing and testing the script.