With new Odata actions, we can now expose any custom business logic from D365, without having to create an custom service.
Apart from using the data entities for data integrations, we can also create and expose the methods too, as Odata actions.They can be used for the process integrations.
For example, using a SalesTable entity to create an Odata action to confirm or invoice the sales order.
For example, using a SalesTable entity to create an Odata action to confirm or invoice the sales order.
Here is the simple example on testing the Odata actions in D365, using a tool called 'Postman'.
So, with this way we can create and expose the custom methods as Odata actions.
The example is for static method, but you can also try with the instance method for the data entity.
For the basic setup and for authentication the below url can be followed:
In this example, I have created a new static method for my custom entity.
The only new thing is, it has been decorated with [SysODataActionAttribute]
This method will invoice the sales order id that has been passed as the argument.
[Your organization's root URL]/data/[Your data entity]/Microsoft.Dynamics.DataEntities.['Method name']
For passing the parameter for the method, we can use the body section:
On clicking the 'Send' button for the POST request, the called method will be executed.
We can go back to D365FO to check if this succeed.
Below is the screenshot, where the mentioned sales order has been invoiced.
We can go back to D365FO to check if this succeed.
Below is the screenshot, where the mentioned sales order has been invoiced.
So, with this way we can create and expose the custom methods as Odata actions.
The example is for static method, but you can also try with the instance method for the data entity.