Checking if Ship Date is past due when Creating Packing Lists

SOLVED

When opening a Sales Order # in Shipping Data Entry, I'd like there to be a message box if today's date is past the ship date of the order. I grabbed this code off of a previous question I asked in this forum and figured I could use most of it for my problem. I just don't know what UDT I should put the script in, or what event should trigger the script, if this code would even work in the first place. I have next to no experience with any of Sage's BOI so if anything seems unclear I'm happy to try and clarify. Thanks.

retVal = 0

sShipDate = ""

retVal = oBusObj.GetValue("ShipExpireDate$", sShipDate)

if oSession.UI <> 0 and d < Date() then
	
	retVal = oSession.AsObject(oSession.UI).MessageBox("Ship Date is Past Due")

end if

Parents
  • 0
    SUGGESTED

    If you want to stop the saving of the record, you should use the pre-write event on SO_InvoiceHeader and use oScript.SetError and pass it the message you want displayed.  As for evaluating the date, you could compare against oSession.SystemDate.  However your code is comparing Date() against a variable called d but it doesn't appear anywhere else.  If you use the event I mentioned, the following should work.

    sShipExpireDate = "" : oBusObj.GetValue "ShipExpireDate$", sShipExpireDate
    If sShipExpireDate < oSession.SystemDate Then
        oScript.SetError "Ship Date is Past Due."
    End If

Reply
  • 0
    SUGGESTED

    If you want to stop the saving of the record, you should use the pre-write event on SO_InvoiceHeader and use oScript.SetError and pass it the message you want displayed.  As for evaluating the date, you could compare against oSession.SystemDate.  However your code is comparing Date() against a variable called d but it doesn't appear anywhere else.  If you use the event I mentioned, the following should work.

    sShipExpireDate = "" : oBusObj.GetValue "ShipExpireDate$", sShipExpireDate
    If sShipExpireDate < oSession.SystemDate Then
        oScript.SetError "Ship Date is Past Due."
    End If

Children