cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Create records in a user table using the Service Layer API

RicardoTorresDev
Explorer
0 Likes
422

I need to know if it is possible to create records in user-created tables using Service Layer API?

I wanted to avoid connecting directly to the database.

 

View Entire Topic
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi RicardoTorresDev,

If it is a No Object type table, you can use the following request in Service Layer:

 

POST b1s/v1/U_MYTBL
{
	"Code":"C", 
	"Name":"CName", 
	"U_F1":"test data"
}

 

Where MYTBL is the table name.

Similarly, if the UDO is defined, you can use the following request:

 

POST b1s/v1/MyOrder

{
    "U_CustomerName": "c1",
    "U_DocTotal": 620,
    "MyOrderLinesCollection": [
        {
            "U_ItemName": "item1",
            "U_Price": 100,
            "U_Quantity": 3
        },
        {
            "U_ItemName": "item2",
            "U_Price": 80,
            "U_Quantity": 4
        }
    ]
}

 

Where MyOrder is the UDO name.

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

RicardoTorresDev
Explorer
0 Likes

@ANKIT_CHAUHAN 

Thank you, it solved my problem.