Skip to Content
0

How to display value to User Defined Field of form in SDK?

Oct 31, 2017 at 01:17 PM

52

avatar image

Hi all,

I created user defined field called (U_return) in SAP B1 document I want to take value in SDK codes and paste it to that user defined field,

The following is my sample codes

    Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
        If pVal.FormType = 133 AndAlso pVal.ActionSuccess = False AndAlso pVal.EventType = BoEventTypes.et_ITEM_PRESSED AndAlso pVal.ItemUID = "1" AndAlso pVal.FormMode = 3 Then
'example of my logic

Dim ReturnValue As Double=20
UDF=ReturnValue

'If I click Add button and then display the value to user defined field and 'then yes in order to save
End if
End Sub 

How can I achieve that?

Please anyone can help me

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Danilo Kasparian Oct 31, 2017 at 01:29 PM
0

string udfFormUID = oApplication.Forms.Item(FormUID).UDFFormUID;

Form UDFForm = oApplication.Forms.Item(udfFormUID);

((EditText)UDFForm.Items.Item("U_return").Specific).Value = "YOURVALUE"

Your UDF Form should be open to work

Show 5 Share
10 |10000 characters needed characters left characters exceeded

Hi Danilo,

Thank you so much, it works.

How can I add that value?

0

What do you mean?

0

The following code gives error message

Dim UDFForm As Form = SBO_Application.Forms.Item(udfFormUID)

Error message is this

Add-on 9000041 failed with exception; Event Type: 16

Full codes are

    Private Sub SBO_Application_ItemEvent2(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent
        If returnVale <> "" Then
            Dim udfFormUID As String = SBO_Application.Forms.Item(FormUID).UDFFormUID
            Dim UDFForm As Form = SBO_Application.Forms.Item(udfFormUID)
            DirectCast(UDFForm.Items.Item("U_return").Specific, EditText).Value = "20"
        End If
    End Sub

What is the problem of error message Add-on 9000041 failed with exception; Event Type: 16 ?


0

Do you have any other ItemEvent? I see that it is ItemEvent2

Also, you are not handling your event, so for any item event you will fall into this code, which can cause issues if you are not in the right form

0

Hi Danilo,

I tried to add all logic in one ItemEvent, it works fine

Thank you so much

0