cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member

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?

Accepted Solutions (0)

Answers (3)

Answers (3)

0 Kudos

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

Former Member
0 Kudos

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

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

former_member185682
Active Contributor
0 Kudos

Hi Prasanna,

I believe that Ankit's answer will solve your problem, all user tables starts with @ not with U_.

But I would like to suggest you read this blog and see an option how to abstract your actions on user defined tables "https://blogs.sap.com/2016/01/23/building-your-framework-to-work-with-sap-b1-part-1/"

Kind Regards,

Diego Lother