Custom Office - User Defined Scripts Help

SUGGESTED

I need help.

I created 2 numeric UDF's for CI_Item; PACK and EACH_COST.  I wanted to automatically calculate EACH_COST by taking the Item's Standard Cost and dividing it by the PACK.

I searched SageCity and found a simple script and modified it.  I am not a scripting expert, but I know enough to be dangerous. IT WORKED! (Script below)

But now, when I "X" out of a blank Item Maintenance screen, I get an ERROR 88.  I'm pretty sure it has to do with the Script interaction with the screen, but I don't know how to trap the error.

PLEASE HELP.

 

Error 88        Invalid/Unknown property name

O/S Error     Overflow

Program       SY_COMMONUI.PVC 

Statement    2105

Class           IM_item_ui

Method        CallScript

EACH_COST SCRIPT

StdUnitCost = 0
PACK = 0

retVal = oBusObj.GetValue("StandardUnitCost", StdUnitCost)
retVal = oBusObj.GetValue("UDF_PACK", PACK)

if (PACK) = isnull then retVal = oBusObj.SetValue("UDF_EACH_COST", 0) else if (PACK) = 0 then retVal = oBusObj.SetValue("UDF_EACH_COST", 0) else retVal = oBusObj.SetValue("UDF_EACH_COST", StdUnitCost/PACK)