oLines not properly filtered for new SO (in header scripts)

SUGGESTED

Issue identified on a 2019 Premium system, but verified on unmodified 2021 Standard with ABC data.

Column post validate script on SO Header (WarehouseCode).

sSalesOrderNo = ""
retVal = oBusObj.GetValue("SalesOrderno$", sSalesOrderNo)
oSession.WriteLog "M", "Running script SO_SetWhseOnLinesFromHeader - Start: " & sSalesOrderNo
Set oLines = oSession.AsObject(oBusObj.Lines)
retVal = oLines.MoveFirst()
do until oLines.EoF
	retVal = oLines.GetValue("SalesOrderno$", sSalesOrderNo)
	oSession.WriteLog "M", "Running script SO_SetWhseOnLinesFromHeader - in the oLines loop: " & sSalesOrderNo
	
	retVal = oLines.MoveNext()
loop ' oLines
retVal = oBusObj.GetValue("SalesOrderno$", sSalesOrderNo)
oSession.WriteLog "M", "Running script SO_SetWhseOnLinesFromHeader - End: " & sSalesOrderNo

What happens when I click Next SO is a long delay, which should not happen.  There are no Lines on a new order, so the script should have nothing to do... but what actually happens is that the script loops through all open SO lines (which is a bug in my opinion).

The work-around is not too hard (adding "retVal = oLines.SetBrowseFilter(sSalesOrderNo)" before the oLines.MoveFirst...) but that should not be necessary.  Can this be fixed please?

Parents
  • 0

    Just curious, does the oLines.MoveFirst() fail?  (I'm guessing it doesn't and returns the first line  of the first order on file)  This is a chicken and the egg issue, because the Warehouse Validation is being kicked off because of the warehouse being set in the SetDefaults() which happens before the lines are actually loaded into memory.  Off the top of my head, this will not be an easy fix, however, let me have a look.  You could also grab the order number from the .MoveFirst() call and see if it matches your current order, but your band-aid is probably a better one.  

    Stay tuned.

    E

  • 0 in reply to jepritch

    Elliott,

    There is no failure (retVal = 1).  The MoveFirst ends up in the first open SO detail record, then MoveNext effectively scrolls through the entire table. 

    Luckily the SetValue / Write in the Live script fails to change anything (because those lines are not entered through the associated SO header), which is why we didn't notice it earlier.  (When I wrote the script on my ABC system, scrolling through all rows is not a big deal, but on the customer system it is a delay of over a minute).

    Edit:

    And thanks for taking a look. Slight smile

Reply
  • 0 in reply to jepritch

    Elliott,

    There is no failure (retVal = 1).  The MoveFirst ends up in the first open SO detail record, then MoveNext effectively scrolls through the entire table. 

    Luckily the SetValue / Write in the Live script fails to change anything (because those lines are not entered through the associated SO header), which is why we didn't notice it earlier.  (When I wrote the script on my ABC system, scrolling through all rows is not a big deal, but on the customer system it is a delay of over a minute).

    Edit:

    And thanks for taking a look. Slight smile

Children