Dynamics CRM 2011 Solutions, Part 1

Introduction to Solutions

Dynamics CRM 2011 Solution Packages (“solutions”, for short) are packages of customizations that allow you to build and maintain Dynamics CRM/xRM applications, and to move them from one organization to another. In fact, not only are they the best practice approach to moving customizations from one CRM organization to another; but short of re-creating every customization from scratch they are the ONLY way to move customizations. So there really is no option not to use them: unless you want to manually recreate every customization any time you provision a new organization, you must use solutions in Dynamics CRM 2011.

A solution is originally created within the context of a Dynamics CRM organization. It’s important to distinguish between the organization a solution is originally created in, and a different organization it gets imported to. I’ll refer to the first one as the “Developer” or “Publisher” organization. Any custom functionality a solution provides (custom entities, workflows, form script, plug-ins, etc.) can be exported as part of a single unit. This unit is referred to as the solution package, and consists of a zipped up collection of XML files. When exporting a solution package from the organization it was developed in, there are two options: you can export a “Managed Solution”, or an “Unmanaged Solution”.

Managed solutions have the following features:

  • When imported to a different organization (you might refer to this as the “Consumer” organization) all of the customizations are automatically published.
  • They can be uninstalled. Uninstalling a managed solution is a clean and complete uninstall: that is, all of a managed solution’s components are removed from the Target organization when the managed solution is deleted.
  • They can selectively expose components for customization in the consumer organization. This is specified in the developer organization, where solution components can be specified as customizable or non-customizable. Customizable solution components of a managed solution are fully exposed and customizable in the consumer organization.
  • Versioning is built in to the managed solution architecture. For example, if “Solution A, version 1″ is imported, and subsequently “Solution A, version 2″ is imported, Dynamics CRM will recognize version 2 as a new version of the same solution and import/publish just the new features.
  • They cannot be modified in or exported from a consumer organization.

 

Unmanaged solutions have the following features:

  • When imported into a consumer organization, their components must be published.
  • They cannot be uninstalled. (Any of their custom components can be deleted, but this must be done one at a time, unlike the one-click uninstall for a managed solution.)
  • They can be modified in or exported from a consumer organization, either as an unmanaged solution or a managed solution.

     

The last bullet-points in both sections may be confusing at first: it seems a little odd at first that you can import a managed solution you’ve created yourself and cannot modify the solution package in the target organization, but it’s true: while you can modify customizable components of a managed solution, you cannot modify the solution package itself, except for in the original (developer/publisher) organization. On the other hand, unmanaged solutions can be further modified in any way in the consumer organization, OR exported from it, either as a managed or unmanaged solution. That’s what unmanaged solutions are for.

Generally speaking, you can say the following:

  • If you’re a commercial software developer, or an enterprise developer/customizer, you will probably use managed solutions to distribute your CRM 2011 customizations: they give you clean uninstall capability, versioning with automatic upgrades, and the ability to selectively lock down components.
  • If you just want to move your customizations from one CRM 2011 organization to another, and don’t want any restrictions on what you can do with them in the target/consumer organization, that’s what unmanaged solutions are for.

 

Solution Components

What can be in a solution? Almost anything you need to customize Dynamics CRM. Suppose you’re just starting out in a brand-new uncustomized CRM 2011 organization, and you start in customizing. If you click Settings, Customizations, and then Customize the System, you’ll open the solution explorer, and although it might not be obvious at first, you will be customizing the default solution. Every organization starts out in an uncustomized state, with its default solution exposed in what can also be referred to as the “unmanaged solution layer”. This is a good place to see all of the different types of components that can make up a solution:

 Solution Components

In subsequent articles in this series I’ll drill down on specific components, but you can tell from scanning the list that almost everything you do when customizing Dynamics CRM 2011 is customizing a solution component. From one standpoint, the big advantage of the solution architecture is how much farther it pushes the XRM customizations-as-metadata approach. For example, with the addition of html, Jscript, xml, image, and css web resources, we really do have a virtual file system we can use to build much more complex customizations — stored entirely within the CRM database — than was possible in CRM 4.0.

And don’t even get me started about plug-ins!  

Two Solution Examples

Currently there are two great sources of solutions you can use to experiment with and learn from: www.codeplex.com is one, and the Dynamics CRM 2011 SDK is the other. I’ve got high hopes that the Dynamics Marketplace will one day be in that category, but unless I’m missing something obvious, it’s not there yet.

One of my favorite managed solutions is “Advanced Find Mapping”, and you can find it by searching codeplex for “CRM 2011″, or just click here: http://www.codeplex.com/site/search?query=crm 2011

Here’s what it looks like in codeplex:

To get a feel for how a solution like this one works, you can follow these steps (assuming you’ve got the System Administrator security role in Dynamics CRM):

  1. Download the zip file behind the links in the previous figure. The file name is “AdvancedMapping_1_2_0_0_managed.zip” – by convention a managed solution package has the term “managed” in the file name like that.
  2. In Dynamics CRM, click Settings, and then click Solutions.
  3. Click Import to kick off the Import Solution wizard.
  4. Browse out to the zip file you downloaded in step 1, and then click Next.
  5. Optionally, you can click the View solution package details button to see what you’re going to import, then click Next again.
  6. After the solution finishes importing, you should see a message that the solution imported successfully.

After importing a solution you’ll see it in the Solutions grid. If you open up the Advanced Mapping solution you’ll see this:

What they’re doing here is using the Configuration Page feature of solutions to tell you how the solution works. Very nice! If you click on the Information tab in the previous figure you’ll see this:

You can see the Solution Publisher in this figure (more details on the importance of the Solution Publisher in part 2 of the series). You can also see how the Configuration Page is filled in.

This particular solution consists of 11 web resources, and one client extension. The client extension is “Application Ribbons”: they customized the Advanced Find ribbon to expose the mapping functionality. The web resource components include Data (XML), Image (PNG), Script, Style Sheet and Web Page web resource types:

I won’t go into the details of how this managed solution works here, but here’s a comment and a hint to get you started:

  • Notice that “You cannot directly edit the components of a managed solution”. I mentioned that above. But the folks at Boggle exposed their managed solution components as customizable, so you can go out into your default solution – the “unmanaged layer” – and examine the components and make changes if you’d like to.
  • If you want to drill down on this one a little bit, start by checking out the Advanced Find Search Script library.

In the meantime here’s how it works. Go into Advanced Find for accounts, contacts, or leads. You should see the Map icon on the ribbon, and you can just click it instead of the Results button to map your results rather than display them in the normal data grid:

Click Map, then your account records (the ones with address information) will be displayed as push-pins on a Bing map.

This is just an example, but it’s actually useful out of the box: remember it’s mapping the results of a query, not just all active accounts.

Anyway, you can uninstall a managed solution by going back into the solutions grid, selecting it and deleting it. You’ll see a message telling you all of the solution components will be deleted…and sure enough, they will be. EVEN if you’ve customized them. For example, with the Advanced Find Mapping solution, Boggle exposed the Script libraries as customizable components…so you can go ahead and customize them. But if you modify the code in the functions they’ve included, or add your own custom functions to their libraries, and then uninstall the solution, you lose the customizations you’ve made. That’s the way managed solutions are supposed to work, so make sure you don’t modify customizable components if you plan on uninstalling a solution!

There are a number of managed solutions included in the Dynamics CRM 2011 SDK, and besides being good examples of what you can do with solutions, they also include all the source code. Download the SDK from here if you haven’t yet: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=420f0f05-c226-4194-b7e1-f23ceaa83b69

One of my favorites is the REST Silverlight Contact Editor. If you need a lightbulb moment for why you’d want to create a Silverlight web resource for Dynamics CRM, this should do the trick! This solution is contained in the samplecode/cs/Silverlight/restsilverlightcontacteditor folder:

Again, it’s a managed solution, so you can import the package, it just works, and it gives you one-click uninstall. This solution only contains two components, both web resources, one an HTML page and the other a Silverlight (XAP) resource. After importing the solution, navigate directly to the HTML page by following these steps:

  1. Click Settings, Customizations, then Customize the System.
  2. Click Web Resources and locate the “sample_/RESTSilverlightContacEditorTestPage.html” web resource.
  3. Open the form for the web resource and then click the URL at the bottom of the form. You’ll see a sweet Silverlight grid that gives you spreadsheet-style editing of contact records, something a lot of people ask for in CRM:

And it really works, too!

Solutions are important, and as people figure out how to use them we’ll see an explosion of add-ons for Dynamics CRM 2011 and the xRM platform. In Parts 2(…N?) of this series on solutions I’ll go into more detail on how to work with solutions, and topics like the following:

  • how to use managed components to selectively lock down functionality
  • how solution dependencies work
  • how to reference web resources within solutions
  • how solution layering works

In the meantime, you might also consider my CRM 2011 Essentials series: http://www.dynamicscrmtrickbag.com/dynamics-crm-essentials/ The Customizers session coming up on June 3 is all about one of my current favorite topics: How to Work with Web Resources and Solutions.

10 Comments »

  1. Hosk Said,

    May 30, 2011 @ 5:27 pm

    a good introduction to solutions

  2. Srinath Said,

    June 24, 2011 @ 3:40 am

    Hi,
    First of all, thanks Richard for writing such an interesting article about solutions in CRM 2011.
    This article gives a pretty good knowlegde of what solutions are and its types in CRM 2011.
    Looking forward to your next blog, as you have mentioned, which includes how the solution layer works within. It might more interesting!

    Thanks !!

  3. Ian Roberts Said,

    September 13, 2011 @ 6:24 am

    Hi,

    Quick question on the silverlight implementation. I have added the silverlight as a web resource and into my form. How do i get the silverlight loading control to show. I have added a few things to the xap file and its about 2MB now.
    When my form loads its just black(white) until the silverlight loads and then it shows?

    Any ideas?

  4. Bob H. Said,

    December 20, 2011 @ 10:49 am

    Richard, this is awesome. Great example, too – the jScript mapper made some waves around my office. Is Part 2 of this out yet?

  5. Pam Jensen Said,

    January 4, 2012 @ 12:08 pm

    This is a great article. Would love to see Part 2, but haven’t been able to locate it. If it exists, could you post a link?

    Thanks!

  6. Richard Knudson Said,

    January 4, 2012 @ 9:50 pm

    Hi Pam,
    Uh…not quite out yet. got a little backlogged. :-) Thanks for prompting me, though — I’ll push it up in the queue. And thanks for reading!

  7. Bob Said,

    January 11, 2012 @ 3:11 pm

    Question: If I make a Solution that contains an entity and save – then come back a few days later and change+publish the included entity, will the Solution automatically include that update if I export it again? Almost like a dynamic vs static marketing list, if you catch what I mean.

    Thanks!

  8. Richard Knudson Said,

    January 27, 2012 @ 6:56 am

    Hi Bob,

    If I understand your question correctly, the answer is yes. When you export a solution, it will always contain the currently published version of any entities it contains. That “Publish all customizations” option you get when you export is your failsafe option, but if everything is published you don’t need to do it every time you export.

    Cheers, Richard

  9. Paul Matthews Said,

    February 28, 2012 @ 8:45 am

    Hi Richard

    Thanks for taking the time write this article. Have you managed to write part 2.

    Thanks
    Paul

  10. Mohammed Fakhri Said,

    March 13, 2012 @ 8:15 am

    Thanks Richard ,
    will be waiting for Part 2.

Leave a Comment