UDF Calculation

SOLVED

Hello

I want to calculate UDF H, W & D to Volumn Field to get the cubic feet of item:  (H x W x D)/1728. The following formula doesn't work on a prewrite UD script setting. I appreciate help from you expert. Thanks :)

H = 0
W = 0
D = 0
CF = 0

retVal = oBusObj.GetValue("UDF_ID_H", H)
retVal = oBusObj.GetValue("UDF_ID_W", W)
retVal = oBusObj.GetValue("UDF_ID_D", D)
retVal = oBusObj.GetValue("Volume", CF)

if (CF) = isnull then retVal = oBusObj.SetValue("Volume", 0) else if (CF) = 0 then retVal = oBusObj.SetValue("Volume", 0) else retVal = oBusObj.SetValue("Volume", (H*W*D)/1728)

Parents Reply Children
  • 0 in reply to Kevin M

    Thank you Kevin, & Jepritch, how to narrow pop up condition in this. Sorry, not too expert on Vi script. Appreciate your help.

  • 0 in reply to vivian kwok

    retVal = oSession.AsObject(oSession.UI).MessageBox("","Words:  " & sStringVar)

    Put lines like the above in your script (and recompile) to check the values in your variables.  Any numeric values should be converted to string...

    cStr(nNumberVar)

    Doing this will let you know what is working and what isn't.  If your H / W / D values are zero, the other statements are not the problem.

  • +1 in reply to Kevin M
    verified answer

    Thank you Kevin for teaching this. Slight smile

    The final script works as below

    H = 0
    W = 0
    D = 0
    CF = 0

    retVal = oBusObj.GetValue("UDF_ID_H", H)
    retVal = oBusObj.GetValue("UDF_ID_W", W)
    retVal = oBusObj.GetValue("UDF_ID_D", D)
    retVal = oBusObj.GetValue("Volume", CF)

    if (CF) = 0 then retVal = oBusObj.SetValue("Volume", H*W*D/1728)
    if (H)=0 then retVal = oBusObj.SetValue("Volume", 0) end if