VI Import Job Expression Builder IF THEN ELSE Statement

How can I use an IF THEN ELSE statement in the Expression Builder when importing a job? I keep getting a syntax error.

For my current example: I'm looking to import item shipping weights. I already have my import value assigned to Temp001. So now I want to apply a calculation for ShipWeight...If Temp001 is empty, return/assign the current shipping weight that's already in our system, else return/assign the new import value (Temp001).

IF Temp001$="" THEN ${CI_Item.ShipWeight$} ELSE Temp001$

This feels correct, but it returns a "Expression syntax error. Error #26: Variable type invalid." What am I doing wrong? Is there another way I can create an IF THEN ELSE calculation?

  • 0

     You can't use IF THEN ELSE in VI.   You have multiple entries of CI_Item.ShipWeight with conditional statements.  

  • 0

    For the ship weight column I have put a calculation (selected Calculation as operation then clicked the tools beside the Calculation field in Import Field Properties). In the expression text for the calculation enter the following.  It will set item ship weight to Temp001$ if it is not blank otherwise it will set to itself.

    TBL(Temp001$=$$,Temp001$,{CI_Item.ShipWeight$})

  • 0 in reply to daburke

    The TBL function is a good way to handle simple evaluations but you can also use an IF THEN ELSE statement after assigning a valid value or variable matching the field's type followed by a semi-colon.  For what you are trying to do, the following should work.  This should set the default value to CI_Item.ShipWeight value and then it checks if the value in Temp001$ is not blank and if so, it will set the field to the value in Temp001$ by assigning the value to the VAR$ variable (used behind the scenes for each element on the Data tab).

    {CI_Item.ShipWeight$}; IF Temp001$<>"" THEN { VAR$=Temp001$ } END_IF