I have BOI Script in the table pre-write events for SO_SalesOrderHeader and SO_InvoiceHeader that do regular expression searches in the ship to address fields for PO boxes when certain ship via types are used, as most of our ship to addresses should not contain a PO Box entry and cause sales tax problems after the fact. My script works in SalesOrderHeader very well, and works in InvoiceHeader except when doing a credit memo.
If I am processing a credit memo through SO Invoice Header I get a different error other than the SetError message I've said to display. Instead I get "You cannot use a credit card payment credit memo is not applied to an invoice." However, I am doing nothing with the credit card tab or trying to apply the invoice. Does anyone have any ideas as to why I'm receiving a different message when doing a credit memo or how to suppress it and display my SetError message? I've put my script below. We are on version 5.10.3 Sage 100 Advanced ERP 2014.
'Language : VBScript
strShipVia = "" : strMsg = "" : strSTA1 = "" : strSTA2 = "" : strSTA3 = ""
If oSession.CompanyCode = "TFP" Then
Set myRegExp = New RegExp
myRegExp.IgnoreCase = True
myRegExp.Global = True
myRegExp.Pattern = "((P(\.?))\s?(O(\.?))\s?)|(Box)"
retVal = oBusObj.GetValue("ShipVia$", strShipVia)
If strShipVia <> "UPS" and strShipVia <> "UPS BLUE" and _
strShipVia <> "UPS ORANGE" and strShipVia <> "UPS RED" and _
strShipVia <> "USPS" and strShipVia <> "FEDEX" Then
retVal = oBusObj.GetValue("ShipToAddress1$", strSTA1)
retVaL = oBusObj.GetValue("ShipToAddress2$", strSTA2)
retVal = oBusObj.GetValue("ShipToAddress3$", strSTA3)
If myRegExp.Test(strSTA1) or _
myRegExp.Test(strSTA2) or _
myRegExp.Test(strSTA3) Then
strMsg = "Error - PO Box cannot be in ShipTo Address."
retFail = oScript.SetError(strMsg)
End If
End If
End If