Tested in a clean v2018.3 system with ABC data.
' SO header pre-total script
retVal = 0
sItemCode = ""
Set oLines = oSession.AsObject(oBusObj.Lines)
retVal = oLines.MoveFirst()
do until oLines.EoF
retVal = oLines.GetValue("ItemCode$", sItemCode)
if sItemCode = "/DELETE_ME" then
retVal = oLines.Delete()
end if
retVal = oLines.MoveNext()
loop ' oLines
Lines removed by the above script do not get marked as deleted in SO_SalesOrderHistoryDetail, and therefore show up incorrectly in SO history inquiry.
This is clearly a bug, since a deleted line, not on the order, is not showing as deleted in history. Is this a known issue or do I need to open a case?
Edit: script trigger comment corrected.