Help with old code

This works to look up a price and divide it by 2:

Field AdvancedPricing
formulafill
lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Retail»),0)/2

But this (which I’ve tried in various versions) doesn’t work. I need to be able to prepend some text and what used to work (I have old code from Pan 6) isn’t working now:

FormulaFill “~Retail~~1~0.0000~”+str(lookupselected(“PriceSource”,“ItemNum”,ItemNumber,val(“Retail”)/2),0)

Thanks in advance as always!
b

Barry, you have a working formula.

In your second code sample you should use exactly the same syntax:

FormulaFill "~Retail~~1~0.0000~"+str(lookupselected("PriceSource",«ItemNum»,«ItemNumber»,val(«Retail»),0)/2),0)

Trying your suggestion (which would make me happy, believe me!) is generating a “syntax error.”

Looks like Kurt added an extra “,0)” to the end of the formula.Try:

FormulaFill "~Retail~~1~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Retail»),0)/2)

Now fixed. Here’s the whole code fragment:

FormulaFill “~Retail~~1~0.0000~”+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Retail»),0,0)/2)

+"~~~|~Retail9~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Retail_3PlusPrice»),0,0)/2)

+"~~~|~Store1~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Store_SingleTubePrice»),0,0)/2)

+"~~~|~Store9~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«Store_3PlusPrice»),0,0)/2)

+"~~~|~Wholesale1~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«WS_SingleTubePrice»),0,0)/2)

+"~|~Wholesale9~0.0000~"+str(lookupselected(“PriceSource”,«ItemNum»,«ItemNumber»,val(«WS_3PlusPrice»),0,0)/2)+"~~~"

for reasons I don’t know, field names in quotes were causing errors. When I replaced them with the chevron thingies, the errors stopped. By the way, what is the keyboard shortcut for those? «»
thanks again,
b

Well, on my German QWERTZ keyboard you would type the “«” character with opt-Q, the “»” character with shift-opt-Q.

image

1 Like