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?