Skip to main content

Dynamics CRM - error publishing entity, role does not exist

This morning I was trying to add a new option to an option set field for a custom entity I had made earlier, however an error dialog popped up which said "The requested record is unavailable or you have insufficient permission to view the record", even though I'm in a System Administrator role.  Upon downloading the exception details and examining them, the actual error was this:

role With Id = dba45c71-05e2-e311-9210-0050568f0001 Does Not Exist

At one point there were multiple custom roles and multiple forms associated with this entity, configured such that people in an employee role could see one form and people in a manager/admin role could see a different form with more fields, things like that.  Later on this functionality wasn't required so I deleted all but one of the custom forms and roles, however it turns out that this form still had references to those custom roles.

There wasn't much information around about this, and all the solutions I could find were like https://community.dynamics.com/crm/f/117/p/73740/135685.aspx referring to just deleting various things like custom forms, which seemed like a pretty weak solution to me.  I searched the database for a form containing a reference to the missing security role:

SELECT  formxml
FROM    FilteredSystemForm
where formxml like '%dba45c71-05e2-e311-9210-0050568f0001%'


This showed that the form's XML contained the following section right at the end:

<DisplayConditions FallbackForm="true">
    <Role Id="{D2A56150-05E2-E311-9210-0050568F0001}" />
    <Role Id="{DBA45C71-05E2-E311-9210-0050568F0001}" />
    <Role Id="{DB70F508-654A-DD11-BE40-001E4F1B8E8B}" />
    <Role Id="{4F7AF508-654A-DD11-BE40-001E4F1B8E8B}" />
</DisplayConditions>


The MSDN documentation for this section (http://msdn.microsoft.com/en-us/library/gg334497.aspx) shows that you can also use an <Everyone> element instead of the <Role> elements, and since I only had one form now it was no longer necessary to deal with security roles.  I tried updating this the Microsoft-approved way with the form editor, but this threw another error at me when I tried to update it to "Everyone" probably again due to the missing security roles.  So my only option was to edit the form directly in the database, which looked something like this (not the full command - don't copy this):

UPDATE systemformbase
SET formxml = 'loads of XML ending with <DisplayConditions FallbackForm="true"><Everyone /></DisplayConditions></form>'
WHERE formid = 'the form's guid'


Seriously don't copy/paste that or you might wreck your form (I really shouldn't need to say that but you know how people are). Anyway, that solved my problem without needing to delete anything!  Hopefully it helps you solve yours too :)

Comments

Popular posts from this blog

Using WiX to create an event source during install of a .NET framework project

Edit: so I guess I wasn't the only one confused with this stuff, as it's been my most popular post by far!  If I've helped you out or saved you some time, please let me know in the comments :)

In order for this to work, you have to add references to WixUtilExtension and WixNetFxExtension to your WiX project.  Once that's done, add this inside a <Component> element:

<Util:EventSourcexmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"Name="EVENTSOURCEGOESHERE"Log="Application"EventMessageFile="[NETFRAMEWORK40FULLINSTALLROOTDIR]EventLogMessages.dll" />
Obviously replace EVENTSOURCEGOESHERE with your event source name.  NETFRAMEWORK40FULLINSTALLROOTDIR is a property set by the WixNetFxExtension which stores the path to the .NET framework v4 directory, but you can replace this with the corresponding property for the directory containing the relevant EventLogMessages.dll file.  So if you're using the .NET framewo…

How to make yourself a Dynamics CRM 2011 Deployment Administrator

Today I needed to deactivate one of our Dynamics organisations, but when I opened the Dynamics Deployment Manager, I received the following error:

"Only the Deployment Administrators are able to use Deployment Manager. You are not a Deployment Administrator."
Bummer. I did a bit of Googling and found this post by Ronald Lemmen (thanks for pointing me in the right direction!).  Since the Dynamics Deployment Manager is obviously checking the MSCRM_CONFIG database for this information I attached a database trace to it and found that it's executing these queries (among many others):

exec sp_executesql N'SELECT  Id, [DefaultOrganizationId], [IsDisabled], [Name]   FROM [SystemUser]   WHERE ((([Name] = @Name0)) ) AND (IsDeleted = 0) ', N'@Name0 nvarchar(41)',@Name0=N'{My windows domain account}'
exec sp_executesql N'SELECT  Id, [Name], [UniqueifierId]   FROM [SecurityRole]   WHERE ((([Name] = @Name0)) ) AND (IsDeleted = 0) ', N'@Name0 nvarchar…

Umbraco Deployment Checklist

This is primarily aimed at deploying from Visual Studio to an Azure Web App + Azure SQL database, feel free to skip bits that aren't relevant if you're doing other things.

Prerequisites for developing locally:
Visual Studio (obviously)
Ensure IIS URL Rewrite module is installed using web platform installer (other downloads from MS documentation don't seem to work)

Set up Azure:
Make a new SQL Database in Azure, take note of the server name, database name, admin login and admin password.  If you already have a server and resource group, automate with Powershell as shown below (you'll need to replace the param values):
New-AzureRmSqlDatabase -DatabaseName "UmbracoDatabase" -ServerName "TheServer" -ResourceGroupName "Whatever" -Edition "Basic"
Add your IP to the Azure SQL db firewall so Umbraco can connect to it later when running locally
Create a new Azure web app, either manually or via Powershell:
New-AzureRmWebApp -ResourceGroupName…