Dear Readers,
Hope you are all safe and sound!
We are back with the new write up; Sales Order creation via Postman.
Creating a Sales Order in Microsoft Dynamics 365 Business Central using Postman involves interacting with the Business Central Web Services API. Below are the general steps to achieve this. Note that you need to have the necessary permissions and authentication set up to access the Business Central API.
Firstly, need to create a codeunit which includes Sales order creation logic , should be published as webservice
The codeunit have one global Procedure called ‘Insert’
This Insert method let us to read the data sent by postman in Json format of the sales order in which it’s in the variable of Json Object.
The Get JsonToken procedure allows us to read the Json according to the key.
:- We Using GetJsonToken that can get the jsontokenvalue,which will be depending on the necessary datatype to apply AsDate,AsCode procedure’s as necessary.
For create sales order we need to get the document type first, and that will stored as JsonObject.
please make sure to give StringCase document type. As we it will get in lowercase.
Now have to create sales order using procedure named ‘CreateSalesInvoice’ which consists of methods InsertSalesHeader &InsertSalesLines that will allow us to create Sales header and Sales Lines through postman.
Method InsertSalesHeaders:-
Method Insert Sales Lines:-
Once added the codeunit into webservices ,for registering & publish referred to the Microsoft blog create & interact with OData page.
Added the codeunit in webservices:-
Input String : To be given in request header of postman
{
“customerNo”: “01445544”,
“orderDate”: “2022-05-19”,
“documentDate”: “2022-05-19”,
“postinDate”: “2022-05-19”,
“documentType”: “Sales Order”,
“taxLiable”: “false”,
“lines”: [
{
“itemno”: “1896-S”,
“quantity”: 2,
“unitprice”: “1000”,
“unitOfMeasure”: “PCS”
}
]
}
Finally, Sales Order Created through postman –Sales Order No:1005
Check with the Business Central;
We hope this write up will help you all!
Follow our page https://www.linkedin.com/company/madhda-business-solutions-pvt-ltd-mbs/mycompany/ to Stay connected with us to learn more!
For more details, pls visit our website www.madhda.com or contact us on sales@madhda.com
Thanks to all.
Madhda Team