When the user clicks on the button just to the right of the "owner" field on an invoice, I need to find out what owner (hr employee) was selected. I am doing this successfully with the following code:
<B1Listener(BoEventTypes.et_CHOOSE_FROM_LIST, False)> _ Public Overridable Sub OnAfterChooseFromList(ByVal pVal As ItemEvent) Dim ActionSuccess As Boolean = pVal.ActionSuccess Dim form As Form = B1Connections.theAppl.Forms.Item(pVal.FormUID) Dim item As Item = form.Items.Item("225") Dim button As Button = CType(item.Specific, Button) Dim item2 As Item = form.Items.Item("38") Dim item3 As Item = form.Items.Item("222") 'document owner Dim Matrix As Matrix = CType(item2.Specific, Matrix) Dim userID As String userID = ChooseFromList_Value(pVal, item3) End Sub Friend Function ChooseFromList_Value(ByVal zpVal As SAPbouiCOM.ItemEvent, ByVal z_itmOwner As SAPbouiCOM.Item) As String Dim rtnVal As String Dim oCFLEvento As SAPbouiCOM.IChooseFromListEvent Dim ownerName As SAPbouiCOM.EditText = z_itmOwner.Specific oCFLEvento = zpVal If Not oCFLEvento.SelectedObjects Is Nothing Then Dim oDataTable As SAPbouiCOM.DataTable = oCFLEvento.SelectedObjects If oDataTable.Rows.Count <> 0 Then Try rtnVal = oDataTable.GetValue(0, 0) ownerName.Value = oDataTable.GetValue(1, 0) & ", " & oDataTable.GetValue(2, 0) Catch ex As Exception End Try End If End If Return rtnVal end function
The problem is that after I retrieve the information and control returns to the form, the new value is NOT loaded into the owner field, as it normally would. I thought perhaps I needed to load the user (owner's) name into the edittext field, which works, but the associated user ID (key) is not set and I don't know how to do it.
Shouldn't B1 load that field for me even though I retrieving the value? Is there a way to set both the name and the ID?