[BC24] Trouble with advanced Deep Insert using an API page

Ferro
Member Posts: 9
Hello all,
I had this customer requirement to implement in BC24 OnCloud:
Create a new sales order + sales lines using the same API call. This works and the response returns all the information that was created successfully (Both information about the Header and the lines).
I used the REST API URL to deep insert this document and made a copy of Microsoft's APIV2 pages regarding sales documents (Page 30028 "APIV2 - Sales Orders" and Page 30044 "APIV2 - Sales Order Lines").
However, the requirement changed. Now I need to be able to:
Insert the Sales Header
Inser the sales lines
After inserting each Sales Line I have to create X amount of vouchers on another table. (I wrote code on the OnInsert trigger of the Sales Line table so this is done through code).
Return all information including these vouchers (related to that Sales HEader document) created during the API call (in the JSON response).
All in the same API call!
I'm relatively new to this API shenanigans and frankly multiple deep inserts are still a bit overwhelming.
So I ask, is this even possible?
Or should I tell the customer to separate some functionalities?
Thanks in advance.
EDIT: We opted for separating the Insert and create logic from the return logic. So the customer will have to consume the API page and insert the sales order and then my code will create X amount of vouchers (In the same call).
Then they'll have to call the same API page but with GET method and ?expand parameter to get all the info they need.
I had this customer requirement to implement in BC24 OnCloud:
Create a new sales order + sales lines using the same API call. This works and the response returns all the information that was created successfully (Both information about the Header and the lines).
I used the REST API URL to deep insert this document and made a copy of Microsoft's APIV2 pages regarding sales documents (Page 30028 "APIV2 - Sales Orders" and Page 30044 "APIV2 - Sales Order Lines").
However, the requirement changed. Now I need to be able to:
Insert the Sales Header
Inser the sales lines
After inserting each Sales Line I have to create X amount of vouchers on another table. (I wrote code on the OnInsert trigger of the Sales Line table so this is done through code).
Return all information including these vouchers (related to that Sales HEader document) created during the API call (in the JSON response).
All in the same API call!
I'm relatively new to this API shenanigans and frankly multiple deep inserts are still a bit overwhelming.
So I ask, is this even possible?
Or should I tell the customer to separate some functionalities?
Thanks in advance.
EDIT: We opted for separating the Insert and create logic from the return logic. So the customer will have to consume the API page and insert the sales order and then my code will create X amount of vouchers (In the same call).
Then they'll have to call the same API page but with GET method and ?expand parameter to get all the info they need.
0
Answers
-
So all has worked in the end ?United Kingdom0
-
Developer101 wrote: »So all has worked in the end ?
More or less. The customer wasn´t too happy about this approach but we told him it was Microsoft API's standard behavior.0 -
What was wrong with the initial approach? Did you try it first and see if it has worked?United Kingdom0
-
I don't know if anything was wrong or if it was even possible to do what I asked before. I tried many ways to try and get the voucher information returned in the JSON response in postman but it always came empty.
It works fine if you send SalesHeader -> SalesLines -> Voucher information in the JSON request. But I can't do that. Each voucher entry must be created after inserting each Sales Line through the API page. So I'm using the trigger OnInsertRecord(BelowxRec: Boolean): Boolean of the SalesLines API.
As I understand it, If you send a JSON request with Sales Header fields, you will receive a JSON response with the Sales Header fields that were sent (an so on...), since I'm not sending the voucher block in the JSON request I'm also not receiving them in the JSON response...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions