Solution With Id = 86ac16ec-41d7-4685-a330-0b1c31411260 Does Not Exist

In some rare scenario's you might get the error message "solution With Id = 86ac16ec-41d7-4685-a330-0b1c31411260 Does Not Exist" while deleting a solution. In our scenario this seems to happen after using the holding solution approach. Luckily this can be solved as long as you have access to the SQL database. Note: Direct SQL updates are unsupported, so only perform this action if you're aware of the risks.

The error appears due to some remaining AttributeMap records for virtual attributes. In more detail, when you create an attribute map between two entities for a lookup attribute, it not only creating an attribute map for the id of the entity, but also for the name of that particular lookup. So in case of an account mapping, it creates an attribute map for accountid as well as accountidname. After moving around with solutions, CRM occacionally forgets to update the owning solution id for the 'name' attribute mappings.

You can visualize the relevant attributes using the following query:

SELECT
 a.SolutionId,
 a.SourceAttributeName,
 a.TargetAttributeName,
 pa.SolutionId,
 pa.SourceAttributeName,
 pa.TargetAttributeName
FROM attributemapbase a
LEFT OUTER JOIN attributemapbase pa
 ON a.parentattributemapid=pa.attributemapid
WHERE a.solutionid='86ac16ec-41d7-4685-a330-0b1c31411260'

You'll see the virtual attributes with their parent attributes and the corresponding solutionid according to the attribute map. The mismatch between the solutionid of the attributemap and the solutionid of the parent attribute map is what causes the error while deleting the solution. Updating the solutionid will solve the issue for you. Here's the query to help you perform this action. Obviously you'll need to change the solutionid to the solutionid as presented to you when downloading the error log file:

UPDATE AttributeMapBase
 SET SolutionId = pa.solutionid
 FROM AttributeMapBase
LEFT OUTER JOIN AttributeMapBase AS pa
 ON AttributeMapBase.ParentAttributeMapId = pa.AttributeMapId
WHERE AttributeMapBase.SolutionId = '86ac16ec-41d7-4685-a330-0b1c31411260'

I'm sure Microsoft will fix this issue sooner or later, but for now I hope this post will help you anyway.


Update:
Apparently there are other scenario's when this error occurs as well. When you create a businessrule, then on the database a record will be created in the "WorkflowBase" will be created, as well as one or more records in the "ProcessTriggerBase". For some reason it is possible that the records in the ProcessTriggerBase are not updated to the new solution ID, resulting in an incorrect record. While deleting a managed solution the deletion process recorgnized the non existing SolutionID and causes the delete to stop.

The way to identify the business rule that is causing the issue, you can run the following query:

select ptb.ProcessId, wb.Name, ptb.solutionid, wb.solutionid
from
 
 
ProcessTriggerBase ptb
 
left join WorkflowBase wb on ptb.ProcessId = wb.WorkflowId
where
ptb.solutionid='86ac16ec-41d7-4685-a330-0b1c31411260'

You then can delete this business rule by hand using the advanced find (search for all processes with category=business rule). Once this rule is removed, then the solution can be uninstalled.