Script to track changes to a field in PO

I've written a script to write field values out to a UDT and record a Date, User, and time so that we can have an audit trail of these fields in PO Header.

The audit trail is written whenever a there is a change to the PO. This works fine for manual changes in PO Entry, VI, and whenever a Receipt of Goods or Receipt of Invoice changes values on the header.

 

What doesn't work is when the PO is printed. The order status is changed from "New" to "Open" and the flag for "Print Order" is unchecked by the system. No record is written to the UDT. I am not sure if the script is firing and just not writing anything or if the script is not being initiated.

 

Anyone have any thoughts?

  • 0

    Unfortunately, Purchase Order Printing does not use the business object to change the PrintPurchaseOrders$ and OrderStatus$ fields.  This was done for performance purposes.

  • 0 in reply to Steve Passmore

    Hi, would you be willing to share your script and the set-up for your UDT? Even if it doesn't work for PO Printing, a partial trail would be much better than nothing. Thanks in advance for any help.

    Meg

  • 0 in reply to mtilton

    Just a generic shadow table script on a UDT. Set to run as a column post validate on the status field.

    oShadow = 0

    sPO = ""

    sKey = ""

    sStatus = ""

    sUser = oSession.UserCode

    sDate = oSession.SystemDate

    sOrderType = ""

    sTime = FormatDateTime(Now,vbLongTime)

    retVal = oBusObj.GetValue("PurchaseOrderNo$", sPO)

    oShadow = oSession.GetObject("CM_UDTMaint_bus", "SY_UDT_PO_Audit")

    if oShadow <> 0 then

    Set oShadow = oScript.AsObject(oShadow) ' establish oShadow as an object handle

    retVal = oBusObj.GetValue("PurchaseOrderNo$", sPO)

    retVal = oBusObj.GetValue("OrderStatus$", sStatus)

    retVal = oBusObj.GetValue("OrderType$", sOrderType)

    retVal = oShadow.SetKey(sPO & sStatus & sDate & sTime)

    retVal = oShadow.SetValue("UDF_PO$", sPO)

    retVal = oShadow.SetValue("UDF_STATUS$", sStatus)

    retVal = oShadow.SetValue("UDF_USER$", sUser)

    retVal = oShadow.SetValue("UDF_DATE$", sDate)

    retVal = oShadow.SetValue("UDF_ORDER_TYPE$", sOrderType)

    retVal = oShadow.SetValue("UDF_TIME$", sTime)

    retVal = oShadow.Write()

    else

    ' write out error to the activity log. Scripts should always use "M" for first argument (Miscellaneous)

    ' to differentiate from "E"rrors and "A"ctivity types.

    retVal = oSession.WriteLog("M", oSession.LastErrorMsg & "Unable to update shadow table, need to run Sync when available.")

    end if