What permissions does this script require? It runs on sales order lines. It works with admin, but other users get an error: Invalid/unknown property name, type mismatch 'oSession.AsObject' SY_MAINT.PVC line 3031
I was thinking edit on the sales order (which it obviously has or you couldn't get into the order) and at least view on CI_Item, but users with full access to item maintenance still get the error.
dblUnitPrice = 0
dblStoredUnitPrice = 0
dblStdPrice = 0
sItemType = """"
sItemCode = """"
retVal = oBusObj.GetValue(""ItemType$"", sItemType)
If sItemType <> ""1"" then
Exit Sub
End if
retVal = oBusObj.GetValue(""ItemCode$"", sItemCode)
set oItem = oSession.AsObject(oSession.GetObject(""CI_ItemCode_svc""))
retVal = oItem.SetIndex(""kPRIMARY"")
retval = oItem.Find(sItemCode)
If retval = 1 then
retval = oItem.GetValue(""StandardUnitPrice"", dblStdPrice)
End if
retVal = oBusObj.GetValue(""UnitPrice"",dblUnitPrice)
retVal = oBusObj.GetValue(""UDF_STOREDUNITPRICE"",dblStoredUnitPrice)
If (dblStoredUnitPrice <> 0) and (dblUnitPrice = dblStdPrice) then
retVal = oBusObj.SetValue(""UnitPrice"",dblStoredUnitPrice)
End if