How it works...

Similar to the first recipe, we started by creating a new solution and referenced the correct NuGet packages. We then added the correct library references in step 3.

In step 4, we started by connecting to Dynamics 365 by injecting a simple connection string into the CrmServiceClient class from the Microsoft.Xrm.Tooling namespace.

We then created a collection of requests: a create request for an account and a create request for a contact record. We then passed the request collection to the ExecuteTransactionRequest class. ExecuteTransactionRequest provides the transaction in which to execute the list of requests.

If any of the requests fail, all the other requests roll back. In our example, if the contact-create request fails, the account creation request rolls back.

Given that we have indicated in ExecuteTransactionRequest to return the responses by setting ReturnResponses to True, we can now loop through each of the responses and display the GUID of each of the records created. We can then correlate each of the responses to the requests, as they are returned in the same order as the requests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.15.15