SO_SalesOrderHistoryDetail does not correctly mark lines removed by script.

SOLVED

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.

  • 0

    In SO Options do you have 'Retain Deleted Lines in Orders/Quotes' set to 'No'?

  • 0 in reply to pmaldonato

    It is set to Yes.  (Prompt does the same thing).

    Deleting a line normally (not via script) the deletions are recorded properly, but the script removals are represented incorrectly in history.

  • 0 in reply to Kevin M

    Not really a surprise. Not having history files not updated as a result of artificially changing a file, that is through means other than manual entry, has a long and colorful history.. I would not be surprised if they told you to add a line to update the history file.

  • 0 in reply to BigLouie

    BigLouie,

    While this is custom, I would not say it is being done "artificially".  I'm using the Sage script command from KB 43033.

    It works on the main SO table, but not in the SO history table... which should be automatically performed by the business object.  That is the whole point of BOI scripting. 

    Knowing what extra work is done by the business object and reproducing that in a script... defeats the purpose of using business objects.

  • +1 in reply to Kevin M
    verified answer

    Hi Kevin,

    The history retention is layered in the line entry function of DeleteLine(key).  Try these small changes to your code above

    ' 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
      delRowKey = ""
      delRowKey = oLines.GetKey()
      retVal = oLines.DeleteLine(delRowKey)
     end if

     retVal = oLines.MoveNext()
    loop ' oLines

  • 0 in reply to jepritch

    Thanks Elliot!  I was hoping for something simple.  Alnoor pointed me in a similar direction but I couldn't get the correct syntax (...my fault in not getting the row key properly).