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 –
Once our request object is ready with all input parameters in place, now we would execute it via Xrm.WebApi as follows –
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.