cancel
Showing results for 
Search instead for 
Did you mean: 

Can I Access to User defined Fields Using UI API in SAP B1 9?

salazar_pablo
Explorer
0 Kudos

Dears,

Please their collaboration with this matter.

I need access throught AddOn using UI API, to UDF in Marketing Documents, in order to read the content using specific EditFields.

For Example, i have a UDF named U_MG_State in headers of Marketing Documents, and i tried to read value using the follow Code

        Dim oForm as SAP

        Dim oForm As SAPbouiCOM.Form

        oForm = SBO_Application.Forms.ActiveForm

        Try

            If oForm.TypeEx = "133" Or oForm.TypeEx = "141" Or oForm.TypeEx = "179" Then

                Dim oItem1 As SAPbouiCOM.Item

                Dim oState As SAPbouiCOM.EditText            

               oItem1 = oForm.Items.Item("U_MG_State")

                    oState = CType(oItem1.Specific, SAPbouiCOM.EditText)

                    SBO_Application.MessageBox(oState.Value.Trim)

                    Marshal.ReleaseComObject(oState)

                    Marshal.ReleaseComObject(oItem1)

            End If

        Catch ex As Exception

            Throw New System.Exception(ex.Message)

        Finally

            Marshal.ReleaseComObject(oForm)

        End Try

but in resalted underline, obtain this error.

Item - Invalid item  [66000-3]. Form Unique Id: 'F_70', Item Unique Id: 'U_MG_State'

Thans in advance for your assintance.

Best Regards

Pablo Salazar

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Salazar,

you can use the UDFFormUID property in the Form object of UI API, as in the following example:

SAPbouiCOM.Form oProductionOrder = SBO_Application.Forms.ActiveForm;

SAPbouiCOM.Form oUDFFrm = null;

                                                    try

                                                    {

                                                        oUDFFrm = SBO_Application.Forms.Item(oProductionOrder.UDFFormUID);

                                                    }

                                                    catch (Exception ex)

                                                    {

                                                        SBO_Application.Menus.Item("6913").Activate();

                                                        oUDFFrm = SBO_Application.Forms.Item(oProductionOrder.UDFFormUID);

                                                    }

                                                    ((SAPbouiCOM.EditText)oUDFFrm.Items.Item("U_raDocEntry").Specific).Value = sDocEntryRA.ToString();

                                                    ((SAPbouiCOM.EditText)oUDFFrm.Items.Item("U_raLineNum").Specific).Value = sLineNumRA.ToString();

maik_delly
Active Contributor
0 Kudos

Hi Salazar,

you need to use the item  unique ID of the edittext - you are using the database field name. To get the ID switch on System Information ( View -> System Information ), afterwards you can hover over the edittext and get the id in statusbar.

regards,

Maik

salazar_pablo
Explorer
0 Kudos

Dear Maik,

Thanks for you reply, but SAP show me the name of Database field in the Status bar.

Thanks

Regards

Pablo

maik_delly
Active Contributor

Hi Salazar,

you want to get a value from the UDF form - this is slighty different.

First of all this form type is -133 ( with a leading minus) then I guess you meant an other field ( your sample doesn't fit the screenshot )?

If you "just" want the value of the field there is a much better way of getting it :

oForm.DataSources.DBDataSources.Item(0).GetValue("Fieldname",0).ToString().Trim()

regards,

Maik

josedvm
Participant
0 Kudos

Wow, this solution works, although the docs (SDK Help Center > Developer's Guide > UI API > Introduction > Restrictions) say "You cannot access a DBDataSource used by a system form.".