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.
- Include all customizations in a solution
- Export solution as managed solution
- Import the managed solution (exported from DEV)
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.
To demonstrate it, I will prepare two environments: DEV and PROD.
In the DEV environment, I will create a solution "vn_dev 188.8.131.52". This solution contains a custom entity vhn_test and 2 fields vhn_field1, vhn_field2
Then, I'll export this solution as managed and import it in the PROD environment. After importation, this is how the solution look like :
Now, we don't need the field "vhn_field2" anymore, let's see how to remove it with patch feature. .
Remove field vn_field2 in the DEV environment (make sure this field is removed from main solution vn_dev as well)
Use "Clone solution" to increase the version for the main solution. The version will be changed from 184.108.40.206 -> 220.127.116.11
Export the solution vhn_dev as managed again. You will have a zip file "vhn_dev_1_1_0_0_managed.zip"
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
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.
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.
It's done, let's check our managed solution, the field vhn_field2 was removed in the managed solution.
- This process will work for any components in Dynamics 365 / Dataverse (entity, web resource, plugin,...) not only field
- The solution upgrade might fail if the components has dependencies on it.
- You can only remove components in a managed solution if you are the owner and you previously deployed it as a managed solution.