Web API Actions in Dynamics CRM 2016

By | January 8, 2016

Taking forward our series on using WEB API in Microsoft Dynamics CRM 2016, we will now touch upon a feature that was not available in ODATA v2 of the earlier versions.

ODATA v2 only provided support for CRUD operations. But Dynamics CRM has some special messages/functions for special operations that are beyond the basic CRUD on an entity. To perform these actions in the earlier versions of Microsoft Dynamics CRM, we had to fall back on SOAP messages.

With Web API, actions are now supported. Action is equivalent to requests that are available in Dynamics CRM.

There are predefined Actions defined in Dynamics CRM 2016 that can be executed using Web API. Following is like where you will find the list of Web API actions. https://msdn.microsoft.com/en-in/library/mt607829.aspx

There are three types of Action as listed below.

  1. Unbound actions: It is not bound to any specific entity. i.e the first parameter to such actions does not include the entity. E.g. WinOpportunity, CancelContract etc
  2. Bound actions: It is bound to specific entity. i.e the first parameter to such actions does not include the entity. e.g. – AddToQueue Action
  3. Custom action: It is custom actions developed by developers using Processes.

We are explaining Web API Action called ConvertSalesOrderToInvoice which corresponds to the organization service ConvertSalesOrderToInvoiceRequest. ConvertSalesOrderToInvoice action is not bound to any entity and does not return a value. ConvertSalesOrderToInvoice Action require following parameters.

SalesOrderId: Guid of the order to convert. (This is compulsory parameter)

ColumnSet: List of attributes to retrieve from the created invoice. (This is compulsory parameter)

Below is the code that are used to execute ConvertSalesOrderToInvoice Action.

//This function is used execute the standard action of webAPI

Here is the main Ajax request that execute the Action.

//This function is used to execute the Web API Action

//This function is used to get the client URL

Similar to this you can execute any Web API actions that are listed and your custom action that you developed.

Conclusion:

Web API can be used for executing messages other than CRUD as well.

Everything in Maplytics – Dynamics CRM and Bing Maps integration is now a search away at our Maplytics InfoCentre.

Leave a Reply