2016 - 2020 First oScript.SetError Method doesn't trigger an error message in Lot/Serial Number Distribution

SOLVED

This UDS is a Column Pre-Validate on QuantityShipped against the SO Sales Order Tier Distribution table at version 2016 Std through 2020 Advanced. The SetError doesn't always trigger the error message, but it does fail (i.e. clear) the distribution number entered. The error message appears in the TraceWindow, but not to the user. The code is simple and an Exit Sub is used immediately afterwards (also tried excluding the Exit Sub to allow a normal exit - same result). I always see the same entry in the TraceWindow "SCRIPT/CallScript - VB Run Error: <<message to user>>" whether or not the message is presented. The following three line script reproduces the problem. If a second SetError is run (with the test script just enter a quantity on the same row) then it will present its message. The behavior repeats on a new row.

retVal = oScript.DebugPrint("About to Test")
retVal = oScript.SetError("Test")

Exit Sub

You may also see the Pre-Validation script run twice in the trace which is another issue.

  • 0 in reply to David Speck

    Thanks for the invaluable tips above. Regarding the "typo" - I checked the statement before I responded:

    oBusObj.GetValue "LotSerialNo", LotSerialNo

    It worked exactly as you wrote it. Therefore my (our?) amazement!

  • 0 in reply to David Speck

    Hi David,

    I came across this post because I'm experiencing somewhat of the same issue - basically I'm hoping to simply prevent shippers from shipping an SO if certain conditions (determined by external data using an SQL query) are not met.

    Ideally this would happen at the time the SO number is specified in Shipping Data Entry and not at pre-write after the shipper has spent the time to specify ship qtys on all lines, etc.

    The problem I'm having is I believe similar to the above, but I'm having a little trouble applying your resolution to my scenario.

    What is happening is the following:

    My SalesOrderNo pre-validate event is firing twice - my DebugPrint calls are telling me that the first time it fires, the SalesOrderNo doesn't contain a value, but then fires again immediately - this time the SalesOrderNo has a value, my custom conditions are checked, and in the event that they are not satisfied, the trace window is reporting a SetError call.  However, the set error prompt doesn't appear on screen.  Furthermore - the record at this point ends up being in an 'unstable' state - where the SO Number is still populated, but no further information on either shipping tabs is populated.  Manually clearing out the SO number results in a save prompt.

    INTERESTINGLY - repopulating the SAME sales order number after performing the above results in the script working exactly as expected.  This ONLY happens when populating the exact same sales order number as the previous step.

    Anyways, I'm going to keep playing around with it, but just thought I'd comment on this post to see if, based on what you found with the above distribution object, you might know of a resolution to my scenario.  

    Thank you as always!