/
Enreach.API.Xrm.execute

Enreach.API.Xrm.execute

(Available from v1.5.2 on)

Executes a request (e.g. an action) against Dynamics API.

Parameters:

  • data: the data (payload) to be sent to the API

  • metaData: the metadata of the request

This API function utilizes the same window.postMessage() mechanism as all the rest of Xrm API functions.

According to Microsoft’s documentation, when executing requests, metadata retrieval happens by adding a getMetadata() function to the prototype of the request function.

Request data is serialized to JSON and then sent to a sub-page for processing, using window.postMessage(). Since functions like getMetadata() couldn't be serialized, data and metaData objects have to be passed separately. The final query object with getMetadata() function is assembled within the sub-page which is handling request execution.

Example code to execute a WhoAmIRequest in a custom plugin:

var SampleCustomer = SampleCustomer || {}; SampleCustomer.Plugins = SampleCustomer.Plugins || {}; SampleCustomer.Plugins.whoAmI = async function (context) { var requestData = {}; var metadata = { boundParameter: null, parameterTypes: {}, operationType: 1, // This is a function. Use '0' for actions and '2' for CRUD operationName: "WhoAmI", }; var response = await Enreach.API.Xrm.execute(requestData, metadata); console.log("Your user id is " + response.UserId); };

 

Related content

Enreach.API.Xrm.retrieveRecord
Enreach.API.Xrm.retrieveRecord
More like this
Voice for Dynamics 365 Configuration Guide
Voice for Dynamics 365 Configuration Guide
Read with this
Enreach.API.executeQuery
Enreach.API.executeQuery
More like this
Event Configurations
Event Configurations
Read with this

© Enreach, Mannerheimintie 117, 00280 Helsinki, Finland
+358 40 450 3000, www.enreach.fi