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

  • 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

  • 0 in reply to David Speck

    I put this in and it works but now how I expected it to. I wanted this message box to show up just to remind our shippers that it is past due so that we can change the ship date at our own discretion. With this, it seems like if it is past due, there is no way for Sage to write the invoice. I would like to be able to still go ahead and write the invoice if we decide that it is okay for it to be past due. Is there a way to do this? I apologize, I should have been more clear in the original post. This is definitely a huge step in the right direction.

  • +1 in reply to Jerrad Garrett
    verified answer

    Then you would switch from using oScript.SetError to using MessageBox.

    sShipExpireDate = "" : oBusObj.GetValue "ShipExpireDate$", sShipExpireDate
    If oSession.UI <> 0 And sShipExpireDate < oSession.SystemDate Then
        oSession.AsObject(oSession.UI).MessageBox "", "Ship Date is Past Due."
    End If

  • +1 in reply to David Speck
    verified answer

    Also, you if you don't want the message when you are saving the record, you could potentially move it to the post-validate event on the SalesOrderNo column so it will trigger as soon as they enter the sales order number.

  • 0 in reply to David Speck

    This is exactly what I needed. Thank you so much.