
- METHOD 365 FOR BUSINESS HOW TO
- METHOD 365 FOR BUSINESS CODE
Now we can try to call our bound actions via OData.
If we reach the OData V4 metadata, we can see that now we have the actions published: What happens with the following definitions when we publish the M圜ustomerCard page as web service (here called M圜ustomerCardWS)?
METHOD 365 FOR BUSINESS CODE
GetSalesAmount is a procedure that takes a Code parameter, calls the GetSalesAmount procedure defined in our codeunit and returns the result as response. It takes the context of the call and calls the CloneCustomer method defined in our codeunit. CloneCustomer is a procedure called without parameters. Inside this page, I declare two procedures to call the two methods defined above in our AL codeunit: Here, ODataKeyFields property specify what is the field to use as key when calling the OData endpoint (I want the “No.” field of the Customer record). To publish your action attached to the Customer entity, you need to create a new page like the following and then publishing it as web service: If you declare a function in a pageextension object and you try to reach the metadata of the OData endpoint ( baseurl/ODataV4/$metadata), you will not see the action published. If you try to do this, it will never work! To use OData V4 bound actions you need to declare a function in a page and this function must have the attribute.įor this demo project, I would like to publish the Customer Card (page 21) as OData web service, so the natural thing to do is to create a pageextension object of the Customer Card to add our procedure and then publishing the Customer Card as web service. GetSalesAmount: it gives the total sales amount for a given customer. CloneCustomer: it creates a new customer based on an existing customer record. Calling a procedure in a D365BC codeunit by passing parameters and reading a return valueįor this sample I’ve decided to create an extension with a codeunit that contains the business logic that I want to call via OData. Calling a D365BC codeunit that performs business logic, like creating new entities. There are two main scenarios that I want to cover here: METHOD 365 FOR BUSINESS HOW TO
Unfortunately, documentation about how to use OData V4 bound actions with Dynamics 365 Business Central is quite poor and with this post I would like to help clearing this topic a bit more. Bound Actions are actions related to an entity that you can call via an HTTP call and they can invoke your business logic (functions). Answer: you can call custom Dynamics 365 Business Central functions via ODataV4 by using Bound Actions. Question was: How can I call Dynamics 365 Business Central logic from an external application? Simple answer given by all: you can publish a codeunit as web service and use the SOAP endpoint.īut if I want to use OData? You cannot publish a codeunit as an OData endpoint. I’ve promised this post to some attendees of my last Dynamics 365 Business Central development workshop in Microsoft Italy (c/o Microsoft House) last week.