Skip to Content
0

How can I get value of User Defined Field in SAP B1?

Nov 08, 2017 at 03:31 PM

216

avatar image

Hi all,

How can I get UDF value from system form of SAP B1?

Actually I know how I can get value from field like this

        Dim oForm As SAPbouiCOM.Form
        Dim oEditTotal As SAPbouiCOM.EditText
        oForm = SBO_Application.Forms.GetForm("133", 1)
        oEditTotal = SBO_Application.Forms.ActiveForm.Items.Item("2").Specific

But if I try to use UDF like this it bring error message

        Dim oForm As SAPbouiCOM.Form
        Dim oEditTotal As SAPbouiCOM.EditText
        oForm = SBO_Application.Forms.GetForm("133", 1)
        oEditTotal = SBO_Application.Forms.ActiveForm.Items.Item("U_return").Specific

How can I do that?

Please anyone can help me

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

2 Answers

Best Answer
DIEGO LOTHER Nov 08, 2017 at 06:19 PM
0

Hi Rurangwa,

In this case you need identify if your user field is on the main form or is in the User-Defined Fields form.

If your user field was moved to the main form with IU Edit functionality, the suggestion provided by Ankit should do the work well. But if your field is on User-Defined Fields window, the correct is get the form type equals = -133.

A sample:

SAPbouiCOM.Form oForm = SBO_Application.Forms.GetForm("-133", 0);
SAPbouiCOM.EditText oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("your_user_field").Specific;

Or

SAPbouiCOM.Form oForm = SBO_Application.Forms.Item(SBO_Application.Forms.ActiveForm.UDFFormUID);
SAPbouiCOM.EditText oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("your_user_field").Specific;

But I would like to suggest another approach, if you are trying to get values from header table of the form, in your scenario OINV, you can read directly the DBDataSource.

A sample:

SAPbouiCOM.Form oForm = SBO_Application.Forms.ActiveForm;
SAPbouiCOM.DBDataSource db = oForm.DataSources.DBDataSources.Item("OINV");
string value = db.GetValue("your_user_field", 0);

Hope it helps.

Kind Regards,

Diego Lother

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

Thank you so much, that works fine

0
ANKIT CHAUHAN
Nov 08, 2017 at 04:30 PM
0

Hi,

It should be used something as below:

SAPbouiCOM.EditText oEditDays = (SAPbouiCOM.EditText)oMatrix.Columns.Item("U_NumDays").Cells.Item(SelectedRow).Specific;
SAPbouiCOM.EditText oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("U_Item").Specific;

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Share
10 |10000 characters needed characters left characters exceeded