Two simple Business scripts could be used that would trigger when the cost of an entered Miscellaneous item was found to be zero, then change it to something uniquely non-zero (like -0.001 that avoids the message) and raise a flag (using SetStorageVar). Then when the line is about to be written (PreWrite event) another script checks the flag and if it is up then the value is changed back to zero and lowers the flag.
These will work for all versions 4.40 to 2021:
Event: SO Detail Column Post Validate on QuantityOrdered or ItemCode
Name: "CNX_SZC_SODtl_Bus_CPV_QtyOrd.vbs"
Const MISC_ITEM = "5"
Const TEMP_NOT_ZERO = -0.001 ' Sufficient to bypass as not zero
sItemType = "": retVal = oBusObj.GetValue("ItemType$", sItemType)
nUnitCost = 0 : retVal = oBusObj.GetValue("UnitCost", nUnitCost)
If nUnitCost = 0 And sItemType = MISC_ITEM Then
retVal = oBusObj.SetValue("UnitCost", TEMP_NOT_ZERO)
retVal = oScript.SetStorageVar("RESET_TO_ZERO", True)
Else
retVal = oScript.SetStorageVar("RESET_TO_ZERO", False)
End If
Event: SO Detail Pre-Write
Name: "CNX_SZC_SODtl_Bus_PrW.vbs"
bReset_To_Zero = False : retVal = oScript.GetStorageVar("RESET_TO_ZERO", bReset_To_Zero)
if CBool(bReset_To_Zero) = True then
retVal = oBusObj.SetValue("UnitCost", 0) ' back to zero
retVal = oScript.SetStorageVar("RESET_TO_ZERO", False) 'Lower the flag
End If
------------------------------
Dan Burleson
Software Consultant
Connex Software
Corvallis OR
541-224-6642
------------------------------