Instr formula not working with else if

SOLVED

I'm trying to use multiple instr with else if but I think its only working on the first one. I have a  customer memo code with some sales Brand restrictions and this one that catches third party restrictions. It also catches other stuff like no export and stock level. Any help would be great : )

if {SO_SalesOrderDetail.UDF_RESTRICT} like "*5*" then
if instr({AR_CustomerMemo.MemoText},"NoFulfillment") > 0
then "NoFulfillment"

else if {SO_SalesOrderDetail.UDF_RESTRICT} like "*4*" then
if instr({AR_CustomerMemo.MemoText},"WalMart") > 0
then "NoWalMartSales"

else if {SO_SalesOrderDetail.UDF_RESTRICT} like "*3*" then
if instr({AR_CustomerMemo.MemoText},"Ebay") > 0
then "NoEbaySales"

else if {SO_SalesOrderDetail.UDF_RESTRICT} like "*2*" then
if instr({AR_CustomerMemo.MemoText},"Amazon") > 0
then "NoAmazonSales"

else if {SO_SalesOrderDetail.UDF_RESTRICT} like "*1*" then
if instr({AR_CustomerMemo.MemoText},"NoThirdParty") > 0
then "NoThirdParty"

fyi this is the customer memo code

["NoThirdParty", "Amazon", "Ebay", "WalMart", "NoFulfillment", "MAP", "Boker", "Boker Plus", "Boker Magnum", "Carson Optics", "Dragon by Apogee", "Fox", "Hogue", "5.11 Tactical", "Fisher Space Pen", "Gear Aid", "Gerber", "Havalon", "Leupold", "Medford", "Pelican", "SOG", "Victorinox", "Kai USA", "Shun", "Zero Tolerance","United Cutlery", "Hibben", "Kit Rae", "Black Legion", "Viking Tactics", "Cold Steel"]

Parents
  • +1
    verified answer

    You're probably misunderstanding the order of operations of the ELSE statements, when you don't wrap your nested IF's in brackets.  Here's what your code looks like indented.

    The ELSE on line 5 is for the line 3 IF (not the line 1 IF).  Wrap line 3-4 in brackets to make the line 5 ELSE apply to the line 1 IF.

Reply
  • +1
    verified answer

    You're probably misunderstanding the order of operations of the ELSE statements, when you don't wrap your nested IF's in brackets.  Here's what your code looks like indented.

    The ELSE on line 5 is for the line 3 IF (not the line 1 IF).  Wrap line 3-4 in brackets to make the line 5 ELSE apply to the line 1 IF.

Children