As part of customising forms in Microsoft Dynamics CRM 2011, often you would want to assign security roles to these forms.
I recently came across an issue where I got the following error when trying to publish all customisations – “Record Is Unavailable. The requested record was not found or you do not have sufficient permissions to view it.”
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: role With Id = 7ea68cb0-1c3a-4106-8bca-0895bc32e676 Does Not ExistDetail: http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"> -2147220969 <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" /> <Message>role With Id = 7ea68cb0-1c3a-4106-8bca-0895bc32e676 Does Not Exist 2011-12-05T06:09:56.3220709Z
Turned out that it was because I removed a role that I had previously assigned to a couple of forms in an entity.
When you assign a security role to a form, the form actually references the security role by its GUID. There is no check done by the CRM when deleting a security role to check if the role is a dependant to any of the entity forms.
To identify which entities are affected and causing the problem, and if you don’t know which roles assigned to which forms, you can:
- open the Default Solution,
- try publishing the entities one by one, and
- take note of which ones cause the error above to appear
At this point, you can either delete the forms as the quickest way to resolve the issue, but then you have to re-create the forms. Or you can remove the dependencies by following these steps:
- create a temporary solution that includes the affected entities,
- export it as an unmanaged solution,
- extract and open the customizations.xml file,
- locate where the role IDs are being referenced,
- remove these references,
- update the customizations.xml file in the package with the updated version, and then
- re-import the solution