How it works...

This recipe has two purposes; the first is to demonstrate how you can access external resources, and the second is to demonstrate how you can use extra assembly dependencies by merging them into your own assembly using ILMerge.

In step 1 to step 3, we prepared our plugin to call the external resource using a simple WebClient DownloadString method that effectively sends a GET request to the defined URL. The URL is hardcoded for simplicity; however, in your code, avoid hardcoding external dependency values. Instead, use the plugin configuration as described in Building near real-time integration with Azure Service Bus in this chapter (or some other flexible means). Once we receive the JSON response, we parse it into a JSON array using JArray from the Newtonsoft.Json.Linq namespace and then use the Dynamics 365 tracing service to display the count.

In step 5, we merged our assembly with the Newtonsoft.Json.dll assembly into a new one called Packt.Xrm.Extensions_Merged.dll. Note the name difference. If you have already deployed Packt.Xrm.Extensions.dll in your Dynamics 365 instance, make sure you tidy up your plugin to avoid duplicate plugin executions. Also, note how we sign the new assembly using the /keyfile argument.

Any assembly going to Dynamics 365 online needs to be signed, including merged ones.

In the last two steps, we ran the plugin and observed the tracing output. For more details on how to retrieve tracing logs in Dynamics 365 online, read the Debugging your plugin in Dynamics 365 Online recipe of Chapter 4, Server-Side Extensions. For on-premise instances, read the following TechNet article: https://technet.microsoft.com/en-us/library/hh699694.aspx.

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

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