Skip to main content

Portal Troubleshooting, Part Three: Uninstalling Portal Solutions

Issue: When uninstalling one of the solutions required by a portal in Dynamics 365, an error such as "Cannot Delete Component" is thrown due to a dependency on another solution.


When a portal is deployed, a varying number of solutions (depending on the portal type selected) are automatically installed in the associated Dynamics 365 organization. These solutions are managed, have one of two separate publishers (both labeled "Microsoft"), and typically have "Microsoft" within the solution name. For example, the "MicrosoftCrmPortalBase", "MicrosoftIdentity", and "MicrosoftWebForms" solutions are installed for all portal types.

These solutions are imported into the target organization in a specific and deliberate order, as some solutions have dependencies on the components contained within other solutions. This order is important if the need arises to remove one or more portal solutions from the Dynamics 365 organization, but unfortunately the import order is transparent to the end user during the deployment. Furthermore, when logged into the Dynamics 365 organization itself, the data that is displayed within the Solutions view is a bit sparse and cannot be customized, nor can a user perform an Advanced Find search that targets solutions, specifically.

Uninstall-Solution-Failure-B.png

When a solution is initially imported into Dynamics 365, there are three columns in the organization database’s SolutionBase table that reflect the timestamp of this action – CreatedOn, InstalledOn, and ModifiedOn. As long as none of the solutions have ever been upgraded, we can leverage either of the first two values to determine the installation order of the solutions. And armed with the installation order, we can reverse it to know which order we should uninstall the solutions without triggering any dependency errors.

However, if any of the solutions have been upgraded, then their CreatedOn, InstalledOn, and ModifiedOn values will be overwritten with an entirely new timestamp that reflects the time of the upgrade. As such, reversing the installation order will no longer provide an accurate list for uninstallation, at least for those solutions that were targeted as part of any such upgrade.

Since a Dynamics 365 administrator cannot directly query the organization database for a solution installation order in a cloud scenario, a streamlined method to determine the reverse installation order of these solutions is needed. A list of all possible portal solutions and their pre-defined installation order would also be helpful.

Resolution: To remove all portal entities, record data, and references from a Dynamics 365 organization successfully, the portal solutions must be uninstalled in reverse order. Since the debut of the (extremely useful) Microsoft Dynamics 365 Web API in version 8.0.2, we now have the ability to perform HTTP-based operations to retrieve a variety of data from a Dynamics 365 organization. We can use FetchXML within our query, too, giving us all the tools we need to retrieve a specific set of solutions and sort them in descending order by their "InstalledOn" value.

To access the Web API service document, the base URL of https://[orgname].crm.dynamics.com/api/data/v8.[x] can be used. This document lists all of the available entity sets that can be queried, including "solutions". Therefore, if we append "solutions" to the URL (https://[orgname].crm.dynamics.com/api/data/v8.[x]/solutions), we can retrieve a list of all solutions installed in this organization. But with a little FetchXML magic, this list can also be filtered and joined with other entities, such as the solution publishers available in the organization.

In this case, we want our FetchXML to filter out all solutions except those associated to the publisher with a "customizationprefix" field value of "adx" or "msa", and then list the results in descending order by the "installedon" field value. The final version of the URL would be:

https://[orgname].crm[x].dynamics.com/api/data/v8.[x]/solutions?fetchXml=<fetch mapping='logical'><entity name='solution'><attribute name='installedon'/><attribute name='friendlyname'/><order attribute='installedon' descending='true'/><link-entity name='publisher' to='publisherid'><attribute name='customizationprefix'/><filter type="and"><filter type="or"><condition attribute='customizationprefix' operator='eq' value='adx' /><condition attribute='customizationprefix' operator='eq' value='msa' /></filter></filter></link-entity></entity></fetch>

After authenticating to the Dynamics 365 instance and placing this URL in the browser, the end result is a list of all portal-related solutions in the order that they should be uninstalled (from top to bottom):

{
"@odata.context":"https://microsoftsupport.crm.dynamics.com/api/data/v8.2/$metadata#solutions(installedon,friendlyname,solutionid)","value":[
{
"@odata.etag":"W/\"590188\"","installedon":"2017-02-18T21:54:25Z","friendlyname":"Custom portal","solutionid":"5e76f5e5-e538-435e-bb63-400e532ba4b2","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"590023\"","installedon":"2017-02-18T21:54:02Z","friendlyname":"Microsoft Azure Storage","solutionid":"aef59b0d-ec52-4786-bbe2-bdec93c5536c","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"589803\"","installedon":"2017-02-18T21:53:31Z","friendlyname":"Feedback","solutionid":"6f3462c1-5551-42ea-bd3d-26b8b7e37da9","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"589042\"","installedon":"2017-02-18T21:51:07Z","friendlyname":"Microsoft Web Forms","solutionid":"51bde720-1c52-4748-be52-1e994a64077e","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"583378\"","installedon":"2017-02-18T21:50:45Z","friendlyname":"Microsoft Identity Workflows","solutionid":"c96c79e7-ea0d-425c-97a7-3b5149d6eeb2","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"583263\"","installedon":"2017-02-18T21:50:30Z","friendlyname":"Microsoft Identity System Workflows","solutionid":"3058144c-32c6-45a1-b985-9e77c2a6f3bf","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"583200\"","installedon":"2017-02-18T21:49:53Z","friendlyname":"Microsoft Identity","solutionid":"1abf507f-15fd-40b5-859f-b47629337763","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"582527\"","installedon":"2017-02-18T21:49:17Z","friendlyname":"Web Notification","solutionid":"d502ff22-15ac-4870-90e7-e34df757e0a2","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"582076\"","installedon":"2017-02-18T21:49:02Z","friendlyname":"Microsoft Dynamics 365 Portal Base Workflows","solutionid":"710c9ea3-8a3c-4302-9dbf-f21da2511ee2","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"582028\"","installedon":"2017-02-18T21:48:47Z","friendlyname":"Microsoft Dynamics 365 Portal Base System Workflows","solutionid":"ba055086-9b27-4d84-ba83-e19c50fabff8","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"579847\"","installedon":"2017-02-18T21:43:24Z","friendlyname":"Microsoft Dynamics 365 Portal Base","solutionid":"ba713b86-047e-46df-9148-770682d51e39","publisher1_x002e_customizationprefix":"adx"
},{
"@odata.etag":"W/\"562433\"","installedon":"2017-02-18T21:41:16Z","friendlyname":"Portal Dependencies","solutionid":"a3ed18a6-0238-49e6-b00b-0b30344d6d76","publisher1_x002e_customizationprefix":"msa"
}
]
}


We could place this URL in a URL Encoder (such as this one on Bing) if we wanted to take this a step further, but this isn’t necessary as the URL above will give us the data we need as it stands.

As mentioned above, though, this method begins to lose accuracy if solutions have been upgraded since the original portal deployment. In the event that one or more solutions have been upgraded, I've created the following table that lists all Microsoft-deployed solutions for portals and the order in which they should be uninstalled under normal conditions:

Uninstallation-Order.png



In the event that further assistance is required beyond the instructions provided here, please contact Microsoft support.

Interested in more troubleshooting tips for Dynamics 365 portals? Check out the first installment for an overview of all topics covered throughout this series.

Comments

*This post is locked for comments