Thursday, September 25, 2014

How to delete an old component from your managed solution in CRM 2011/2013

Hi Guys,

Every CRM 2011/2013 developer that create his own managed solution will, sooner or later, face this problem.

If you work in a development environment on an unmanaged solution called Solution Alpha and you want ti export it to a managed solution with version 1.0.0.0 when you have finished your development, that generate a compressed file called : SolutionAlpha_1_0_0_0_managed.zip.

This solution contains for exemple :
 - Three custom entities : (sa_business, sa_turnover and sa_relationship)
 - One custom dashboard : (Actual Turnover)

Now after two or three months, you worked hard and you upgraded your unmanaged solution. You will exported it in a managed solution with version 2.0.0.0, that generate a compressed file called : SolutionAlpha_2_0_0_0_managed.zip.


This new version of your solution contains :
 - Four custom entities : (sa_business, sa_turnover, sa_marketingplan and sa_statistics )
 - Two custom dashboards : (Actual Turnover, Statistics)

But there is no sa_relationship entity in the new version because in the new version, this entity is obselete.

When your client import the new version in his organization, he will see that the version changed but when he see the entities list, he will find the sa_relationship entity although this entity has been removed from the new version.

And because, it's a managed solution, your client will not be able to remove this entity mannually.

Here is an illustration of the situation on the organization of the client :


If your client thinks to remove the version 1.0.0.0 of the solution before importing the new version, he will lost all data created with the first version.

Because, when we remve a managed solution we remove the data also,

WHAT CAN YOU DO TO RESOLVE THIS PROBLEM  ??????

Here is the solution :

Inevitably, you should use a Holding Solution.

the principle of Holding Solution is to hold data available in the organization when you delete the old version.

To do it you should fellow these steps:

1 - You should extract the new solution version SolutionAlpha_2_0_0_0_managed.zip in a separate folder.
2 - Open the solution.xml file.
3 - Go to Uniquename tag and change it to HoldingSolutionAlpha like this :

  1. <ImportExportXml version="6.0.0001.0061" SolutionPackageVersion="6.0" languagecode="1033" generatedBy="OnPremise" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  2.   <SolutionManifest>
  3.     <UniqueName>HoldingSolutionAlpha</UniqueName>
  4.     <LocalizedNames>
  5.       <LocalizedName description="Holding Solution Alpha" languagecode="1033" />
  6.     </LocalizedNames>

4 - Save the solution.xml file.
5 - Re-compress and rename the solution floder as HoldingSolutionAlpha_2_0_0_0_managed.zip.
6 - Now, if we make an inventory of solutions we will have three solutions:
    * Solution Alpha version 1.0.0.0 already installed in your client organization.
    * Solution Alpha version 2.0.0.0
    * Holding Solution Alpha version 2.0.0.0
7 - Connect to the client organization, and go to Settings > Solutions.
8 - Import the solution HoldingSolutionAlpha_2_0_0_0_managed.zip
9 - Delete the solution Solution Alpha version 1.0.0.0
     don't worry, the holding solution will keep your data available.
10 - Import the solution Solution Alpha version 2.0.0.0
11 - Delete the solution Holding Solution Alpha version 2.0.0.0

Now if you look at your solutions subgrid you will see only the Solution Alpha version 2.0.0.0.
And guess what ? There is no sa_relationship entity in the client organization.

Good Luck.

7 comments:

  1. Is this a supported approach?

    ReplyDelete
  2. I am intrigued too if this a supported customisation?

    ReplyDelete
  3. In response above, it is a supported way to cross this issue as you are not touching the physical data on the back end. As long as it's a managed solution that you created, then you should be good to go, however, if you try this on an external solution, you may run into contractual issues.

    As with anything, I would definitely recommend taking a backup of the org/instance before any work is performed, however, you shouldn't have any support issues if something happens.

    ReplyDelete
  4. I did fail to say, Elegant solution, Well done! :)

    ReplyDelete
  5. The step 11 and 12 makes no sense to me. Why are you re uploading the same solution with separate name in solution.xml, just to change the name of solution?

    ReplyDelete
  6. This could have been done without going for Holding solution as if directly import the final solution, it could have hold the data.

    ReplyDelete
  7. Step 10 - Import the solution Solution Alpha version 2.0.0.0 doesn't make any sense.
    As per explanation, that solution is already imported. Then what do you actually import ?

    ReplyDelete