You can remove all unmanaged customizations from a solution component. This is very handy if somebody did some customizations in your managed environment and you want to revert it. Having unmanaged customizations on managed components can be really annoying as they overrule your managed changes.
This blog will show how to do this via the user interface and via the API. It works for many different component types like forms, sitemap, web resources and business rules. Not every component type is supported at this moment, however Microsoft is adding more over time. You can see a list of all types here.
Removing unmanaged customizations via the UI
To remove the unmanaged customizations via the UI, you start by opening a solution that contains the component (default solution works fine). Select it and navigate to the ‘Solution Layers’ (see screenshot below). The classic editor is used, because at the time of writing, the button doesn’t exist in the new editor yet.
After opening you get a list of layers. This view shows the solutions the component is included in and their order. The unmanaged layer is called ‘Active’. When you click on the 3 dots a dropdown will appear that says ‘Remove Active Customizations’ (see screenshot below). When you click it and confirm the dialog, the customizations will be removed. Removing the customizations can take some seconds.
If the ‘Active’ layer doesn’t have the 3 dots, that means that the component doesn’t support the removal of the unmanaged customizations yet. In that case you will need to be patient until it is added.
Removing Unmanaged Customizations via the API
Removing customizations via the API can be done using an OrganizationRequest. This request is called ‘RemoveActiveCustomizations’. If the component doesn’t have an active layer, it just do nothing. There won’t be any exception. It has two parameters:
- ComponentId: This is the GUID of the component.
- ComponentType: This is the name of the component. If the name has any spaces (like App Module in the screenshot below), then remove them
It is also possible to retrieve all the solution layers of a solution component. You can do that with the ‘RetrieveSoltionMetaDataForComponent’ request. As it can take like 10 seconds per removal of an active layer, so checking if it has an active layer can reduce the processing time by quite a bit if you have many components to check. This request has 3 parameters:
- SolutionComponentName: Component Type. Same as the ComponentType parameter from the previous request.
- ColumnNames: These are the names of the columns you want to filter on for this component type. As you already have the GUID of the component, you should always filter on the ID field
- ColumnValues: Values of the columns you want to filter on.