SO lines loop, updates only one line

SOLVED

I have a script, which edits line data (conditionally) based on a header event trigger.  It works fine in v2020, but in v2022 (Standard, no enhancements) only one line is updated.  In order to get it to update all lines, I had to add a check for a changed value, and MoveFirst() to restart the loop at the top... which shouldn't be necessary.

If I take out the Write(), the loop works, but in v2022 it seems like the oLines.Write() somehow causes EoF.

Set oLines = oSession.AsObject(oBusObj.Lines)
retVal = oLines.MoveFirst()
do until oLines.EoF
	sItemType = "" : sLineWhse = ""
	retVal = oLines.GetValue("ItemType$", sItemType)
	retVal = oLines.GetValue("WarehouseCode$", sLineWhse)
	if (sItemType = "1" and sLineWhse <> sWhse) Then
		retVal = oLines.SetValue("WarehouseCode$", sWhse)
		retVal = oLines.Write()
		retVal = oLines.MoveFirst() ' this should not be needed?!?
	end if
	retVal = oLines.MoveNext()
loop ' oLines

(Sage, if you want the full script / event, just message me and I'll send it to you).

Parents Reply Children