Skip to Content
author's profile photo Former Member
Former Member

how to insert data into User defined table in sap B1 Sdk C#

hi

I am trying to Insert Data into User defined Table in Database.

I wrote like this

SAPbobsCOM.UserTable oUserTable; oUserTable = Ocompany.UserTables.Item("U_Registrations"); oUserTable.UserFields.Fields.Item("RowId").Value = 1; oUserTable.UserFields.Fields.Item("Name").Value = txtName.Text; oUserTable.UserFields.Fields.Item("ContactNo").Value = txtContactNo.Text; oUserTable.UserFields.Fields.Item("DOB").Value = txtDOB.Text; oUserTable.UserFields.Fields.Item("Age").Value = txtAge.Text;

oUserTable.Add();

I am getting error : Invalid field name error in this line

SAPbobsCOM.UserTable oUserTable; oUserTable = Ocompany.UserTables.Item("U_Registrations");

how to resolve this.can any one suggest me?

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • Posted on Jun 08, 2017 at 11:52 AM

    Hi,

    I think you are providing the TableName or FieldName incorrect. You have provided the TableName as "U_Registrations". Is it correct?

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 09, 2017 at 03:56 AM

    yes Ankit.It's correct.I created "U_Registrations" table manullay in Sqlserver SBODemoIN Database.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi,

      What do you mean by manually? You should create the table from SAP Business One Client or using DI API having following types:

      1. No Object Type

      2. Master Data

      3. Master Data Rows

      4. Documents

      5. Documents Rows.

      Only after that you will be able to use the above mentioned code. Also creating the tables manually from SQL Server can cause the Database Upgrade Failure.

      Hope it helps!

      Kind regards,

      ANKIT CHAUHAN

      SAP SME Support

  • Posted on Jun 09, 2017 at 07:58 AM

    User tables (UDT) need to be created via DI or client app. Manually created tables cannot be accessed in this way.

    Add comment
    10|10000 characters needed characters exceeded