Using LINQPad for Dynamics CRM Development

Using LINQPad for Dynamics CRM Development

You are likely already familiar with the excellent development tool LINQPad and if you are a Dynamics CRM Developer you, hopefully, are familiar with LINQPad Plugin for Dynamics CRM. Using LINQPad along with the LINQPad CRM Plugin is a great way to learn the ins and outs of writing LINQ queries for Dynamics CRM. In this article I will show you how, with just a minimal of effort, you can start using LINQPad to directly call Dynamics CRM. This will allow you to go beyond just building LINQ queries and execute code to test Request/Response messages, QueryExpression retrieval, FetchXml, and much more. Using LINQPad allows you to test and learn in real-time without waiting to compile your code and execute your test cases (if you even have test cases! You do have test cases, right?) ...

November 1, 2013 · 7 min · Nicolas Nowinski

Dynamics CRM 2011: Prep Plug-in for XrmToolbox

Originally published at http://goo.gl/bkewP1 ​I can’t really take a lot of credit for this post. All of the difficult work was done by a couple of Dynamics gurus. XRM Prep Plug-in This is a plugin for XrmToolBox (http://xrmtoolbox.codeplex.com/) by Tanguy Touzard. Great thanks to Tanguy for releasing XrmToolBox and providing really solid documentation on how to create Plug-ins for it. XrmToolBox and his numerous other very useful Dynamics CRM tools, which all now run in XrmToolBox, are a great value to the Dynamics CRM community. The idea, implementation logic, and solution file that are the basis for this plug-in are the work of Marc Schweigert from Microsoft. His excellent blogging has been the source of great education for me about how to get the most out of Dynamics CRM. The XRM Starter solution file and the code were published by him in the blog post linked to below. http://blogs.msdn.com/b/devkeydet/archive/2013/01/22/getting-a-new-crm-2011-organization-ready-for-xrm.aspx You must install XrmToolBox on your machine to use this plug-in (http://xrmtoolbox.codeplex.com/). After installing XrmToolBox copy the Procetrnix.CleanForXRM.Dll file to the same directory that XrmToolBox.Exe is installed. Run XrmToolBox and you should see the XRM Prep listed as one of the modules under the Home tab. This plug-in is intended to be used against a new Dynamics CRM organization prior to making any customizations to prepare it for custom development, it can perform the following: - Install the XRM Starter solution file from Marc’s post. Hide the existing reports. Remove all the non-required security roles. Remove the standard dashboards. There are four checkboxes that allow you to select what all you want XRM Prep to handle for you. If you do not want the solution file to be imported you should uncheck Import Solution, etc. When you are ready click on Run in the toolbar at the top of the tab to run the process. You’ll see a status screen while the work is being done and a message box will inform you when it is completed. If you want a copy of the solution file you may download it from the link in Marc’s blog article (URL above) or you can click the Export XRM Solution File from the toolbar to export the file. The DLL exposes a public class, XrmSolutionSetup, that can be used by any .NET 4.0 code. XrmSolutionSetup has a method called Execute that expects to be used as the delegate for BackgroundWorker.DoWork. Thus, this code could be reused in another solution if you did not want to use XrmToolBox. One idea would be to implement this in a console application or PowerShell script that deployed and configured a new organization to start development. Here is the plug-in DLL: http://sdrv.ms/11pTAIn If you want to modify it for your own purposes or just see how it was implemented here is the source:http://sdrv.ms/11pTMaB No guarantees or anything…the source code is there so make it do what you want it to do. I hope this will help you speed up development work and inspire a couple people to make use of the great platform that Tanguy has given us with XrmToolbox.

January 31, 2013 · 3 min · Nicolas Nowinski

Dynamics CRM 2011: Finally...Enterprise ALM for Dynamics CRM 2011

Originally published at http://goo.gl/XXm6z5 ​I wanted to bring your attention to two items that can be very useful for all of us working on Dynamics CRM. As you are aware, CRM customization and development has never really worked well with enterprise focused application lifecycle management (ALM.) The export capability (even with Solutions in 2011) has never worked very well with source code control and change management. In addition, scripting of builds and deployments for customizations have never been what I would call straight-forward or even possible. In the SDK released for Rollup 10 a Solution Packager command-line application that takes an exported solution file and breaks it up into its individual pieces. This combined with the command-line Solution Export tool in the MSCRM Toolkit provides the pieces necessary to automate CRM solutions in a system such as TFS or Git. (http://intovsts.net/2012/12/28/integration-of-dynamics-crm-2011-solutions-with-tfs/) Of course, the next request in enterprise development is automated deployment. As a holiday gift to the CRM world ADXStudio released a beta of their ADXStudio ALM Toolkit (http://community.adxstudio.com/products/adxstudio-alm-toolkit/) - licensing and pricing have not been announced so we’ll have to wait and see. This toolkit includes PowerShell Scriplets that allow for creating organizations and user and automated deployments of solutions, it includes a number of PowerShell scripts to demonstrate usage. It also includes a very valuable command-line tool to copy data from a source system to a file and then import the data during a deployment – this is especially useful for simplifying the process of loading configuration/base data during deployment. Taken together these tools provide the pieces necessary to fully automate the build and deployment process for Dynamics CRM. Many environments do not need this level of automation and the overhead for these tools has to be justified by the requirements. That said, for those environments where the needs justify the time/expense of full ALM it is good to know the requirements can be met with using pre-built tools.

December 28, 2012 · 2 min · Nicolas Nowinski

Dynamics CRM 2011: Simplifying the Request Response Model

Originally published at http://goo.gl/C1n3Hw If you have worked with the Dynamics CRM 2011 SDK you are probably very familiar with the Request/Response model messages in Microsoft.Crm.Sdk.Messages. As a developer trying to write good code I always want to wrap any service call in a Try/Catch statement to provide proper error handling. Another goal is to keep the code as neat as possible for when I – or someone else – has to go back and read it. Wrapping calls in Try/Catch statements increases the total lines of code it takes to implement functionality and makes the code more difficult to read. Recently I was working on a project where I had several of these calls in a row: Execute a request, process the response, build a new request, execute, etc. etc. While I was looking at the code I realized that my catch routine was basically the same (format a message for the user and exit out of the program – in addition to sending a number of execution details to the tracing service). Since the code was getting very long, my first thought was to refactor each of these calls into its own method. While this approach would make my code a bit cleaner, it was still somewhat limited in value. After thinking about the problem a bit more, I decided this would be a perfect opportunity to implement generics, extension methods, and delegates. If you are unfamiliar with any of these topics, here is a super quick introduction: - Generics allow us to create a method without having to know all the input types or the response type thus allowing the developer to specify them when calling the method. Extension methods allow us to create static methods against an existing class without having to inherit to a new class thus we do not disturb any code already relying on the class we want to extend. Delegates let us take a method (that matches the specified signature) and pass it as a variable. You can find out more about each of these concepts in the MSDN documentation links provided. Before we get too far into the details we should review the issue we are trying to resolve. Here is a very basic CRM plug-in that executes a WhoAmI request and gets a WhoAmI response. As I count it there are 6 statements with the try/catch but not including the PluginSetup (see my previous post athttp://goo.gl/lEaa9), to complete the request. It may not seem like a lot, but in the real-world those calls also have logging and the request probably has actual properties that need to be set. No matter what request message you use the basic pattern will remain the same. public void Execute(IServiceProvider serviceProvider) { var p = new PluginSetup(serviceProvider); var req = new WhoAmIRequest(); WhoAmIResponse response = (WhoAmIResponse)p.Service.Execute(req); ...

September 22, 2012 · 9 min · Nicolas Nowinski

Dynamics CRM 2011: Abstracting Plugin Setup

Originally published at http://bit.ly/RIxgt9 How people do it today… Often times when looking at Dynamics CRM plugin code that someone else has written – or that I have written in the past, I’m presented with a large collection of setup and validation code at the start of the Execute method. Overtime it becomes obvious that this is simply cluttering up our core Plugin code with what is really overhead infrastructure work. ...

August 11, 2012 · 5 min · Nicolas Nowinski

Dynamics CRM 2011: Check Team Membership

Originally published at http://bit.ly/OPyMVn The team in Dynamics CRM 2011 provides an ability to group users, assign record ownership to a group of users, and extend security roles to users based on their team membership (as opposed to individually assigning the role.) Teams in Dynamics CRM 2011: A team is a group of users. This organizational structure enables groups of users across an organization to share information. Each team must be associated with only one business unit. A team can include users from any business unit, not only the business unit with which the team is associated. Users can be associated with more than one team. More details can be found in the Dynamics CRM 2011 SDK Documentation. Beyond allowing cross-business unit record access and assignment of security roles, the Team entity can provide a simple way to create a group of users. ...

August 11, 2012 · 3 min · Nicolas Nowinski