Execute action using Xrm.WebApi.online.execute in Dynamics 365 CRM V9.0

By | January 7, 2019

Introduction:

In this blog, we are going to explore the use of Xrm.WebApi.online.execute to execute an action in Dynamics CRM version 9.0 and then process its response which will be consistent across Web client, UCI, Mobile and Tablets. For sample purpose we would execute an Out-of-Box action named “InstantiateTemplate”.

Solution:

First of all, we would define a request and populate the input parameters as shown in the following sample code –

Xrm.WebApi.online.execute in Dynamics 365 CRM V9.0

Once our request object is ready with all input parameters in place, now we would execute it via Xrm.WebApi as follows –

Xrm.WebApi.online.execute in Dynamics 365 CRM V9.0

If the result of executed action is fine(i.e. result.ok == true) then you can read your response via result.json() as it will parse your response consistently across all clients(web, UCI, tablet & mobile).

Note: While passing ids to action make sure you use key as “guid” as shown in the above sample. Also the typename in metadata may differ depending on your parameter’s data type.

Hope it helps.

Multiple Language Map

One thought on “Execute action using Xrm.WebApi.online.execute in Dynamics 365 CRM V9.0

  1. Kokulan Eswaranathan

    Thanks. This actually is one of the cleanest approach that i have seen to call an action from JS. I used to rely on the Action Message generator to to call an action from JS. From now on will be using this as its much easier and REST approach. Thanks again

    Reply

Leave a Reply to Kokulan Eswaranathan Cancel reply

Your email address will not be published. Required fields are marked *