Mon, 04/05/2021 - 10:14 By Nguyen Van Hao Contributor Lloyd Sebag
1 comment

Delete components in Dataverse managed solution:

We usually work with managed solutions and unmanaged solutions in CRM. Please refer to this article to understand more about the solution in Dynamics

In the normal deployment process, we should at least three env (DEV, TEST, PROD) let's simplfiy it to ony two environments for the purpose of this article. 

  1. DEV 
    • Include all customizations in a solution
    • Export solution as managed solution
  2. PROD 
    • Import the managed solution (exported from DEV)

delete components in Dataverse managed solution

Let's imagine you did something wrong in your solution, you removed a component in DEV and you want to remove that component in PROD as well. For example: remove an entity, field, web resources,...

Dynamics 365 does not allow us to remove component directly in a managed solution but we can do this with Solution Upgrade

Let's do it.

Prepare data

To demonstrate it, I will prepare two environments: DEV and PROD.

In the DEV environment, I will create a solution "vn_dev 1.0.0.0". This solution contains a custom entity vhn_test and 2 fields vhn_field1, vhn_field2

delete components in Dataverse managed solution

Then, I'll export this solution as managed and import it in the PROD environment. After importation, this is how the solution look like : 

delete components in Dataverse managed solution

 

Now, we don't need the field "vhn_field2" anymore, let's see how to remove it with patch feature. .

Step 1

Remove field vn_field2 in the DEV environment (make sure this field is removed from main solution vn_dev as well)

Step 2

Use "Clone solution" to increase the version for the main solution. The version will be changed from 1.0.0.0 -> 1.1.0.0

delete components in Dataverse managed solution

Step 3

Export the solution vhn_dev as managed again. You will have a zip file "vhn_dev_1_1_0_0_managed.zip"

Step 4

Import solution vhn_dev_1_1_0_0_managed.zip to PROD environment, select "Upgrade (recommended)" in the import wizard and wait for the import process completed

delete components in Dataverse managed solution

Step 5: Check result

After the import process completed, we'll see a new solution was imported, don't worry, this is a normal process of the Solution Upgrade. This new solution will be removed automatically later. This process is asynchronous and runs in background. 

solution5

If you look at the "Solution history", you will see the detail of "Upgrade process" contains 2 steps: install the new version, uninstall the old version.

solution6

It's done, let's check our managed solution, the field vhn_field2 was removed in the managed solution.

solution7

 

Notes

  1. This process will work for any components in Dynamics 365 / Dataverse (entity, web resource, plugin,...) not only field
  2. The solution upgrade might fail if the components has dependencies on it.
  3. You can only remove components in a managed solution if you are the owner and you previously deployed it as a managed solution.

delete components in Dataverse managed solution

Comments

Tried that in order to remove an event handler, with no success.

I had mistakenly passed twice the event handler - the first one with the pass execution context checked, and the second one unchecked. Then imported it as the article explains.

I removed the second one in a new solution and exported it as managed.

Thu, 06/30/2022 - 02:00
Anonymous (not verified)

Add new comment

Image CAPTCHA
Enter the characters shown in the image.