Hello,
I'm simply wanting to write the previous item code to a UDT when the line is changed in a sales order. For example, if the item code was abc123 and a user changed it to def456, I want to write abc123 to the UDT. However, each time I try to access the line in the history file, the script always writes the new item code (def456) to the udt and not the old one. It seems as if the new item is being written to the sales order history file before the record is written, even though my script is table pre-write.
Is there a way to do this? Why is the new value already stored in the history file even though this script accesses it before I write the new value? I have tried accessing the "Previous" lines through all of the history business objects with the same result. I have been stuck on this for quite some time and would greatly appreciate some help!
itemC = ""
soNumb = ""
retVal = oBusObj.GetValue("SalesOrderNo$", soNumb)
set oLog = oSession.AsObject(oSession.GetObject("CM_UDTMaint_bus", "SO_UDT_SO_CHANGE_TRACK"))
Set oHist = oSession.AsObject(oSession.GetObject("SO_SalesOrderHistoryInquiryDetail_bus"))
retVal = oHist.SetKeyValue("SalesOrderNo$", soNumb)
retVal = oHist.setKeyValue("SequenceNo$", 1)
oHist.Find()
retVal = oHist.GetValue("ItemCode$", itemC)
oLog.SetKey(itemC)
oLog.Write()
Edit: This script is tied to the sales order header