PostLoad SetControlProperty

SOLVED

I have two UDTs that are being used to manage credit releases. One contains the credit release data and the other is just used as a validation table that contains status codes and their descriptions.

In SO Order Entry there is a UDF that uses the main UDT as a validation table so it can pull the read-only fields over as well. One of those fields is the Status Code field, but I am wanting to replace the code with the description that is displayed on a new tab in Sales Order Entry.

When running this code from a button script it works just fine, but on the panel's post-load event it does not.

Const sUDT_CreditRel = "SO_UDT_CREDIT_RELEASES"
Const sUDT_StsCodeCR = "SO_UDT_CR_STATUSCODES"

Dim nCredRelUDT, oCredRelUDT, nStsCodeCR, oStsCodeCR

nCredRelUDT = oSession.GetObject("CM_UDTMaint_bus", sUDT_CreditRel)
nStsCodeCR  = oSession.GetObject("CM_UDTMaint_bus", sUDT_StsCodeCR)

If nCredRelUDT <> 0 Then
    Set oCredRelUDT    = oSession.AsObject(nCredRelUDT)
    If nStsCodeCR <> 0 Then
        Set oStsCodeCR = oSession.AsObject(nStsCodeCR)
        
        'Obtain current sales order number from Main table for UDT's key lookup
        Dim sOrderNo:  sOrderNo = ""
        retVal = oBusObj.GetValue("SalesOrderNo$", sOrderNo)
        
        'Set current record to sales order (.Find) then obtain Order's C/R Status
        Dim sCurrSts:  sCurrSts = ""
        retVal = oCredRelUDT.Find(sOrderNo)
        retVal = oCredRelUDT.GetValue("UDF_STATUS$", sCurrSts)
        
        'Take status code and perform lookup for the description text of the status
        Dim sDesc: sDesc = ""
        retVal = oStsCodeCR.Find(sCurrSts)
        retVal = oStsCodeCR.GetValue("UDF_DESCRIPTION$", sDesc)
        
        'Replace the text box (UI Only) containing raw status code with the code's description
        retVal = oUIObj.SetControlProperty("ALB_UDF_CRNO_UDF_STATUS", "VALUE$", sDesc)
        
        Set oStsCodeCR = Nothing
        oSession.DropObject nStsCodeCR
    End If
    Set oCredRelUDT = Nothing
    oSession.DropObject nCredRelUDT
End If

Any thoughts?

  • 0

    I've also tried using:

    retVal = oSession.AsObject(oScript.UIObj).SetControlProperty("ALB_UDF_CRNO_UDF_STATUS", "VALUE$", sDesc)

    which doesn't seem to work either in the postload event (but it also works when running from a button script).

    -----------------

    Another observation. I placed a messagebox right before the script was to set the property value. It doesn't appear the data has been loaded yet during this postload event. I have tried a few post-read events on both the main SO Header & UDT table.

    So I guess I am not even certain which event this needs to be attached to and if the script itself is even sufficient. But in the screen shot below, the 'Status' textbox would just show "APPROVED" - the code's description that shows in the MessageBox is what I am attempting to replace this text with.

    The information on this tab all comes from the ChildHandle for my UDT. It's loaded because I have the UDT's Key set as the validation to SO Header's field that is named UDF_CR. Because of this the UDT's data can be loaded in a read-only mode and its fields can be placed onto the UI. The UDT data is all managed via script and isn't input manually into this form.

    I suppose if all else fails I can have users press a button script to get the code's description manually if they don't know what "HLDPNCRS" means... But I would like to know where I am going wrong with these event scripts.

  • +1
    verified answer

    From the lack of response I assume this is a technical limitation of Sage.

    I just went into DFDM and deleted the #24 "Nomads_Tag$" property of this control which links the control to its datasource. With the control now unbound the value that has been set by the script during the postload event is no longer overwritten.