One of the best ways to integrate Microsoft Dynamics 365 Business Central with other systems is through APIs. They offer the possibility to trigger Business Central logic through Bound Actions. In this article, you will learn what are they, how to use standard bound actions, and how to create custom ones.
- What Are Bound Actions
- Available Bound Actions
- How To Use Bound Actions
- Custom Bound Action Example
What Are Bound Actions
Bound actions in Business Central refer to actions that are linked to a specific data set. These actions allow users to perform custom business logic within Business Central through APIs.
They are particularly useful when users want to perform specific actions on a particular data entity, such as a sales order.
Bound actions can be utilized together with the Power Platform, enabling users to automate processes and integrate Business Central with other applications.
Available Bound Actions
You can see a list of all available bound actions by searching for “[ServiceEnabled]” in the BC repository called “ALAppExtensions”.
You can find it here:
With the following result.
Or directly in VS Code once you clone the repo. You will find a list of objects available, at this moment 25 API pages with 62 bound actions:
How To Use Bound Actions
First, identify the action to run.
These actions can be used via Power Platform. For example, in a power automate flow. From here you can also explore the list of bound actions available.
We can use Postman to call bound actions as well. This can be done by making a POST request like shown below. If the actions succeeded you will receive a “204 No Content” response.
Note that you must provide the sales invoice ID in this case to post it.
If you use OAuth in Postman, you need to follow a setup first. Find a detailed guide in the following article.
Custom Bound Action Example
Apart from the standard bound actions, you can create custom ones. You can do it by following a specific structure.
In your custom API, create a new procedure with these characteristics.
- [ServiceEnabled] is the first attribute you have to set before the procedure.
- Call the procedure whatever you like.
- It must have “var actionContext: WebServiceActionContext” as the only parameter. It provides methods for interacting with web service actions.
- Although it’s not mandatory, it is a good practice to set the result of the operations by using “SetObjectType”, “SetObjectId”, “AddEntityKey”, and “SetResultCode”.
A built custom API with a bound action can look like this.
In Postman, you have to build the endpoint to call the outbound action. You have to follow this structure if you are using custom APIs:
https://api.businesscentral.dynamics.com/v2.0/<Environment Name>/api/<API Publisher>/<API Group>/<API Version>/companies(<Company GUID>)/<EntitySetName>(<Entity ID>)/Microsoft.NAV.<procedure Name>
This is an example of the “Car Brand” API bound action. Returning “204 No Content” when the result was successful.
Be aware that these types of actions are bound to a specific entity and record. If you try to run this request without specifying an ID, you will get the following error.
You can find more information in Microsoft’s documentation:
Creating and Interacting with an OData V4 Bound Action – Business Central | Microsoft Learn
That´s all. Hope you find it helpful.