Automatically Save Changes on Event Script

Without going in to the whole story we are trying to update some fields for auditing purposes and don't want the user to have the option to not save the changes to the order thus not having a record of the auditing information we are looking for. I have a script tied to SO_SalesOrderHeader Post-Read that only runs if a stored variable is a 1. When this is the case I am trying to automatically save my changes to the sales order and close the sales order but I can't seem to get this working...

I have tried this:

IF nUpdate = 1 THEN
retVal = SSScript.SetStorageVar("Update", 0)
nUpdate = 0
retVal = oScript.DebugPrint("Update " & nUpdate)
retVal = oScript.InvokeButton("BT_Accept")
retVal = oUIObj.HandleScriptUI()
END IF

I get the following error -

Error 88..... invalid/unknown property name

O/S Error.... Object required: 'oUIObj' (err/ret=2/0)

Program.... SY_MAINT.PVC

Statement.... 3031

Class.... SO_SalesOrder_Bus

Method... CalScript

I have played around with trying to use retVal = oBusObj.Write() but am not having any luck... Any advice fellow scripters?

  • 0

    On table event scripts, the oUIObj variable isn't automatically given an object handle, it is up to your script to test if the oScript.UIObj property is greater than 0, if it is, then set it by using


    Set oUIObj = oSession.AsObject(oScript.UIObj) 


  • 0

    Also, see if this accomplishes what you are after.

    Insert this code in your IF...THEN block.


    sSalesOrderNo = "" : oBusObj.GetValue "SalesOrderNo$", sSalesOrderNo
    oBusObj.Write
    oBusObj.Clear
    oScript.DeactivateProcedure "PostRead"
    If oScript.UIObj > 0 Then 
        oSession.AsObject(oScript.UIObj).InvokeChange "SalesOrderNo", sSalesOrderNo
    Else
        oBusObj.SetKey sSalesOrderNo
    End If
    oScript.ActivateProcedure "PostRead"


  • 0 in reply to David Speck

    Hi David,

    Thank you for the response. We have unfortunately moved away from Sage due to a merger as of about two years ago. Hopefully your answer helps someone out there!