Bound Actions in Dynamics NAV & Business Central
Bound Actions in Dynamics NAV and Business Central
Since Dynamics NAV 2018, the possibility of using “Bound Actions” was introduced. Surely it’s interesting because before, it was necessary to use workarounds (these workarounds are available in the various forums \ blogs) to simulate the pressure of a key recalling a function, now with this integrated technology, is certainly more convenient and similar to other tools in which they were already available (ex: CRM).
About Bound Actions…
“You can publish a Dynamics NAV or Dynamics 365 Business Central function as an OData (Open Data Protocol) V4 web service action”.
Before Bound Actions
You could manage the four basic CRUD operations (Create, Read, Update, Delete) data through OData / REST interface.
There was no direct way to call custom code or specific actions like posting a journal.
After Bound Actions introduction…
Now, you can publish a Dynamics NAV or Business Central function as an OData V4 web service action, that means that we can use “Bound Actions” to run specific actions.
These features (Bound Actions) were already available in other tools\applications, but not for Dynamics NAV & BC without using any Workaround. Almost twenty years ago, they were already possible with Microsoft Access…. And now they are also usable in NAV \ BC. Great.
http://<Server>:<WebServicePort>/ODataV4/Company(‘CRONUS%20International%20Ltd.’)/SalesOrders(<Document Type>,<No.>)/NAV.Post Bound Action
In this case we are calling the “Post function” existing in “Sales Order” page.
“Bound Actions” in Action…
Is also now possible to declare OData “bound actions in AL”; a new attribute and a new AL type have been introduced to achieve this.
Declaring the OData bound action
The following example (in link below) shows you how you can declare an OData bound action on a page exposed as a web service.
For that, you need three simple STEPS
#1 – Add a procedure to the SalesInvoiceCopy page.
procedure Copy(var actionContext: WebServiceActionContext)
#2 – Expose the procedure using the [ServiceEnabled] attribute
#3 – Use the WebServiceActionContext and WebServiceActionResultCode AL types to set the result of the function.
NB: Limitations: “Bound actions cannot be added by extending an existing page that has been exposed as a web service.”
Test Web Service – HTTP Request
Example: Copy an Invoice