Automatically Setting Ship Date a Month Out

When creating a sales order, is there a way to automatically set the ship date a month away from today? I always seem to forget to change it and it causes a lot of problems with On-Time delivery. I was hoping there might just be a setting or something that by default will set it a month away and from there, I can change it if a customer requires a due date that is sooner.

Parents Reply Children
  • in reply to Kevin M

    Although having it automatically set a month out for me would be nice, just having the pop-up like you mentioned would be good enough and would probably prevent less room for error in the script. Could you easily change your script to account for all customers? If so, is there any way I could get this script off of you? If not, I understand but it would probably save me a lot of time haha.

  • in reply to Jerrad Garrett

    That specific script has more features than I mentioned, but I'll give this away because it's not too complex.  (Normally I don't post complete scripts because selling such things is how I make a living... plus it encourages people to learn themselves, which is what this kind of forum is all about).

    Untested, so there may be a typo.  Be sure to enable Allow External Access in Company Maintenance.

    retVal = 0
    sOrderDate = "" : sShipDate = ""
    retVal = oBusObj.GetValue("OrderDate$", sOrderDate)
    retVal = oBusObj.GetValue("ShipExpireDate$", sShipDate)
    
    if oSession.UI <> 0 and sShipDate = sOrderDate then
    	retVal = oSession.AsObject(oSession.UI).MessageBox("Ship Date = Order Date")
    end if

    Add the script using UDS maintenance, save, then add the trigger (using the created UDS) on SO header's "PreWrite" event using UDF/UDT maintenance.

  • in reply to Kevin M

    This works perfectly, I greatly appreciate it. I was trying to work it out by myself before you replied but could not get the syntax down. I'm pretty new to coding and scripting so even Excel VBA takes me a while to figure out. Personally, I learn more seeing code like this and going through each line and attaching it to some kind of logic and using it for later reference, rather than trying to write the code myself the first time. Once I put this in place, will everyone in my company get this box pop-up every time they make a Sales Order with the same Ship Date and Order Date?

  • in reply to Jerrad Garrett

    They have to close and reopen SO entry to load the script, but yes, it should apply to everyone.

    The trigger I recommended runs when you click Totals, not when you click Accept, so you have a chance to change the date before saving.

    Sage City has lots of code snippets, so if you need examples, read the forum history.

  • in reply to Kevin M

    I've been messing with the code a little bit today to try to get a message box if an order has a ship date older than the current date. I'd like it to pop up whether it's when I am creating an Sales Order or editing one. I don't get an error code but it doesn't give me a pop-up box. I'm not exactly sure what logic is behind "if oSession.UI <> 0" but that is the only thing I would suspect would prevent the message box from popping up. Would this be why? If not, what would be causing it? I've been looking around for something similar on the forums and can't seem to find anything about it. If this is something you wouldn't usually answer that's understandable and I don't expect you to answer it. Any help is appreciated. Thanks.

    retVal = 0
    
    sShipDate = ""
    
    retVal = oBusObj.GetValue("ShipExpireDate$", sShipDate)
    
    
    if oSession.UI <> 0 and sShipDate < Date() then
    	
    	retVal = oSession.AsObject(oSession.UI).MessageBox("Ship Date is Past Due")
    
    end if

  • in reply to Jerrad Garrett

    The oSession.UI filter is just to prevent the script from running when there is no UI (like when an order is being updated while posting an invoice batch).

    The Sage date format is different than the format for your Date() returns so you are comparing apples to oranges. 

    Search these forums for FormatDate and GetFormattedDate to learn more.

  • in reply to Kevin M

    Alright thank you for giving me some direction. I appreciate it.