Forms and Security Role Assignments

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=5.0.0.0, 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:

  1. open the Default Solution,
  2. try publishing the entities one by one, and
  3. 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:

  1. create a temporary solution that includes the affected entities,
  2. export it as an unmanaged solution,
  3. extract and open the customizations.xml file,
  4. locate where the role IDs are being referenced,
  5. remove these references,
  6. update the customizations.xml file in the package with the updated version, and then
  7. re-import the solution
Advertisements

One thought on “Forms and Security Role Assignments

  1. Hi,

    I also faced same issue. I tried your solution but it didn’t work for me.

    Then I thought of deleting those forms from the entities which are carrying the references.

    And it did the magic for me. I spent almost 4 hours in this struggle but finally the managed solution is removed.

    Thanks for your solution. It gave me the direction.

    Thanks
    Mac

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s