Scripting
We have a script at a client where we are currently using ObusObj.SetValueNoValidate to assign a value to the freight field on the sales order header.
we are using the ""NoValidate"" option because we get an object not found error if we use ""SetValue"".
problem is sometimes the freight is not rounded if we use NoValidate.the really odd thing is that we use ""SetValue"" later in the same script and that processes without error. Can anyone look at this code and tell me if we are just missing something obvious? I can't figure out why the same command would error on one line in the script and work fine on a different line.
The text of the code is below but if you look at the screenshot that I've attached, you will see which line errors and which one works.
myTaxableAmt = 0
myNonTaxableAmt = 0
myTotalInvoice = 0
myDiscountAmt =0
myFreeFreight = """"
myUseCustUpsAccount = """"
myRetVal = oBusObj.GetValue(""UDF_FREE_FREIGHT$"",myFreeFreight)
myRetVal = oBusObj.GetValue(""UDF_USE_CUST_UPS_ACCOUNT$"",myUseCustUpsAccount)
IF myFreeFreight <> ""Y"" THEN
IF myUseCustUpsAccount <> ""Y"" THEN
myFreightAmt = Value
myFreightAmt = ROUND(myFreightAmt,2)
myRetVal = oBusObj.GetValue(""PaymentType$"",myPaymentType)
myRetVal = oBusObj.GetValue(""TaxableAmt"",myTaxableAmt)
myRetVal = oBusObj.GetValue(""NonTaxableAmt"",myNonTaxableAmt)
myRetVal = oBusObj.GetValue(""DiscountAmt"",myDiscountAmt)
myTotalInvoice = myTaxableAmt + myNonTaxableAmt - myDiscountAmt
IF myPaymentType = ""AMEX"" THEN
myNewFreightAmt = ROUND((myTotalInvoice * .02) + myFreightAmt,2)
myRetVal = oBusObj.SetValueNoValidate(""FreightAmt"", myNewFreightAmt)
ELSEIF myPaymentType = ""DISC"" THEN
myNewFreightAmt = ROUND((myTotalInvoice * .02) + myFreightAmt,2)
myRetVal = oBusObj.SetValueNoValidate(""FreightAmt"", myNewFreightAmt)
ELSEIF myPaymentType = ""MC"" THEN
'myNewFreightAmt = (myTotalInvoice * .02) + myFreightAmt
myNewFreightAmt = ROUND((myTotalInvoice * .02) + myFreightAmt,2)
myRetVal = oBusObj.SetValueNoValidate(""FreightAmt"", myNewFreightAmt)
'myRetVal = oBusObj.SetValue(""FreightAmt"", myNewFreightAmt)
ELSEIF myPaymentType = ""VISA"" THEN
myNewFreightAmt = ROUND((myTotalInvoice * .02) + myFreightAmt,2)
myRetVal = oBusObj.SetValueNoValidate(""FreightAmt"", myNewFreightAmt)
Else'Do nothing
myRetVal = oBusObj.SetValue(""FreightAmt"", myFreightAmt)
END IF ' end of myPaymentType
END IF
END IF