cancel
Showing results for 
Search instead for 
Did you mean: 

Choose from list button doesn't load textbox when I intercept CFL event

Former Member
0 Kudos
138

Greetings,

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?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

After loading the values to the data table try to store the values in a String and then assign it to the specific textBox Control..If u have any queries reply...

Regards

MohanaKrishnan.S

Former Member
0 Kudos

Thanks for your reply!

I don't understand what you mean, though, about loading the values to the data table. And am I right to load only the user's name? I need for the user code (key) to be assigned too, but I don't know how to do that.

Thanks again

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi John,

I have explained what I am trying to say in this Code , Take an example of Vendor code and name need to load in the respective Text Boxes.....


    If oCFLEvento.BeforeAction = False Then
                Dim oDataTable As SAPbouiCOM.DataTable
                oDataTable = oCFLEvento.SelectedObjects
                Dim VendCode As String = Nothing
                Dim VendName As String = Nothing
                Try
                    VendCode = CStr(oDataTable.GetValue(0, 0))
                    VendName = CStr(oDataTable.GetValue(1, 0))
                Catch ex As Exception
                    VendCode = ""
                    VendName = ""
                End Try
                Try
                    oEText = oForm.Items.Item("EditText5").Specific
                    oEText.String = VendCode
                Catch ex As Exception
                    oEText.String = VendCode
                End Try
                Try
                    oEText = oForm.Items.Item("EditText4").Specific
                    oEText.String = VendName
                Catch ex As Exception
                    oEText.String = VendName
                End Try
            End If

This will load the CFL values selected in the respective Text Boxes and this Solves your problem.

Thanks and Regards

Mohan.

Former Member
0 Kudos

Hi, thank you.

"This will load the CFL values selected in the respective Text Boxes "

The problem is that I'm using a system form - invoices/deliveries, etc. It has a field (textbox) called "owner" (which is the user name - last name, firstname). So in your example, I am loading "vendor name", with no problem. The problem is the system has no analogous textbox field for "vendor code". I assume your example is on a form you created, not a system form?

When the user clicks the icon to the right of the field, I do CFL processing much like you describe. I am only doing it to catch the user ID so that I can retrieve info about that user. But when I access the CFL data, the system no longer returns the user name to the textbox, so that is my real problem. If I could retrieve the user ID & the system still loaded the field like normal, then things would be great.

Because it isn't doing so, I figured I would load the text box with the name myself. But How do I tell the system the ID of the newly selected user - it must still have the old value in the data source, but of course, we can't change values in a data source on a system form.

Thanks again for everyone's help and perseverance!

Former Member
0 Kudos

Hi John,

In order to ' tell the system the ID of the newly selected user ' try with the Conditions of the CFL value selected so that It will restrict the data displayed in the CFL form the DataSource accordingly.

Thanks and Regards

Mohan

Former Member
0 Kudos

Hi John

Trying with the following (in your item event function):

If BeforAction =false then

dim bREFRESH_FIELD as boolean

Select Case pVal.EventType

Case SAPbouiCOM.BoEventTypes.et_VALIDATE

Select Case pVal.ItemUID

Case "222"

If pVal.ItemChanged = True Then

CALL ONAFTERCHOOSEFROMLIST

End If

End Select

Case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST

Select Case pVal.ItemUID

Case "225"

If pVal.InnerEvent = True Then

bREFRESH_FIELD = True

End If

End Select

Case SAPbouiCOM.BoEventTypes.et_GOT_FOCUS

Select Case pVal.ItemUID

Case "222"

If pVal.InnerEvent = True And bREFRESH_FIELD Then

CALL ONAFTERCHOOSEFROMLIST

bREFRESH_FIELD = False

End If

End Select

END SELECT

end if

I think thats ok for you.

I had this problem (similar problem) and this solved my problem

Former Member
0 Kudos

Hi John

Trying the following:

Friend Function ChooseFromList_Value(ByVal zpVal As SAPbouiCOM.ItemEvent, <b>ByRef</b> z_itmOwner As SAPbouiCOM.Item) As String

the parameter in ChooseFromList_Value named "z_itmOwner" should be ByRef (instead Byval)

I hope useful for you and waitting for reply

Kinds Regards

Former Member
0 Kudos

Thanks, Alejandro.

You are right that it should be by reference. interestingly, I was still able to change the user name which appears in the textbox. But even after changing the parm to ByRef, I still have the problem where the linked button displays the old user not the one who's name I added on the screen. How do I change the user code "behind the scenes" to make the linked button (golden arrow) bring up the newly selected user instead of the old one?

(Hopefully I have mentioned that this problem occurs when the user clicks on the little icon just to the right of the owner textbox - and that's when I do the CFL processing)