We have a variety of customers that we have "special instructions" for when placing an order. I have previously set these to show in a pop-up message box when the Customer Number is entered. I am trying, however, to not have to program each of these individually, so I have added a new tab to the Customers form with a UET field for Special Instructions. My goal is that when the corresponding Customer Number is entered in a Customer Order, a pop-up message will show with whatever was entered in the UET field. I have successfully extended the IDO for Customer Orders and bound the UET field to a property. My problem is getting the Uf_jcm_CusSpecInst value when the Customer Number is entered on the Customer Orders form. When I run diagnostic, the variable value is blank and only shows when the form is saved. Here is an example of form script that I have attached to the CustNumChanged event and where I have it set on Enable Components to set the Variable:
Sub CheckForSpecInst()
Dim MsgTitle As String
Dim MsgPrompt As String
Dim SpecInst As String
MsgTitle = "Special Instructions"
SpecInst = ThisForm.Variables("vCusSpecInst").Value
If ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("CustNum") = "SUF0100" Then
MsgPrompt = SpecInst
MsgBox(MsgPrompt, MsgBoxStyle.OkOnly, MsgTitle)
End If
End Sub
Function EnableComponents() As Integer
Dim PriCache As IWSIDOCollection
Dim bSetEnabled As Boolean
Dim bBlanket As Boolean
Dim bLineExists As Boolean
Dim CoNum As String
Dim CustNum As String
Dim UseExchRate As String
Dim CustomerUseExchRate As String
Dim bInvoiced As Boolean
Dim SpecInst As String
Dim bOrigSite As Boolean
EnableComponents = 0
On Error GoTo ErrorHandler
PriCache = ThisForm.PrimaryIDOCollection
'Set bOrigSite
If PriCache.GetCurrentObjectProperty("OrigSite") <> "" And _
Application.Variables("Parm_Site").Value <> "" And _
(Not String.Equals(PriCache.GetCurrentObjectProperty("OrigSite"), _
Application.Variables("Parm_Site").Value, StringComparison.OrdinalIgnoreCase)) Then
bOrigSite = False
Else
bOrigSite = True
End If
' Only originating sites can change the status.
If Not PriCache.IsCurrentObjectNew Then
bSetEnabled = bOrigSite
Else
bSetEnabled = True
End If
ThisForm.Components("StatEdit").Enabled = bSetEnabled
ThisForm.Components("StatGridCol").Enabled = bSetEnabled
'I believe there's no need to check for new record here
'Get special enable flags
CoNum = PriCache.GetCurrentObjectProperty("CoNum")
CustNum = PriCache.GetCurrentObjectProperty("CustNum")
UseExchRate = PriCache.GetCurrentObjectProperty("UseExchRate")
CustomerUseExchRate = PriCache.GetCurrentObjectProperty("CusUseExchRate")
SpecInst = PriCache.GetCurrentObjectProperty("Uf_jcm_CusSpecInst")
ThisForm.Variables("vCoNum").Value = CoNum
ThisForm.Variables("vCustNum").Value = CustNum
ThisForm.Variables("vUseExchRate").Value = UseExchRate
' Initial values for the flags taken from the GetCoCompEnableFlagsSp code.
ThisForm.Variables("vEdiOrder").Value = "0"
ThisForm.Variables("vLcrRequired").Value = "0"
ThisForm.Variables("vEnableOrderType").Value = "1"
ThisForm.Variables("vEnableConsolidate").Value = "1"
ThisForm.Variables("vEnableEffExpDate").Value = "1"
ThisForm.Variables("vCusSpecInst").Value = SpecInst