Skip to Content
0

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

Jun 08, 2017 at 10:00 AM

355

avatar image

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?

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

3 Answers

ANKIT CHAUHAN
Jun 08, 2017 at 11:52 AM
0

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

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

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

0
Prasanna P Jun 09, 2017 at 03:56 AM
0

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

Show 1 Share
10 |10000 characters needed characters left 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

0
Michal Hadrys Jun 09, 2017 at 07:58 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded