Using OData unbound actions
OData unbound actions are actions that you can invoke via HTTP requests and that are not bound to a particular entity. Unbound actions are useful to execute custom Dynamics 365 Business Central code from external applications.
To use unbound actions in Dynamics 365 Business Central, you need to:
- Create a codeunit exposing your custom actions (procedures).
- Register and publish the codeunit as a web service from Dynamics 365 Business Central.
- Invoke the action via a POST OData call (passing the required parameters in the request body).
Imagine that we have an AL procedure that calculates the total amount of sales orders for a particular customer. The procedure is defined in a codeunit
object as follows:
codeunit 50200 "PKT Unbound Actions"
{
procedure GetSalesAmountForDay(CustomerNo: Code[20]) totalSales: Decimal;
var
SalesLine: Record "Sales Line";
begin
SalesLine.SetRange...