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 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}" />

The MSDN documentation for this section ( 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 :)


Popular posts from this blog

'A section using configSource may contain no other attributes or elements' error after installing Application Insights

After installing the Application Insights nuget package to an Umbraco solution, you'll get this error:

A section using 'configSource' may contain no other attributes or elements

<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
     <log4net configSource="config\log4net.config">
             <level value="ALL" />
             <appender-ref ref="aiAppender" />
Source File: \project\web.config

This happens because part of the Application Insights installation process adds a <log4net> section to web.config.  Which would make sense, except Umbraco already has a <log4net> section in /config/log4net.config.  So as you can imagine, the solution is to manually move everything its added into that file. Unfortunately you can't just copy/paste the whole lot, but it's not particularly complicated:

Move <appender-ref ref="aiAppender" /> into the lo…

Handling double-quoted CSVs in Azure Data Factory Pipelines

Azure Data Factory by default uses a backslash as the escape character for CSVs, but we ran into an issue with this today processing one of the CSV files from  As with most CSVs they use quotes around values as normal and with double-quotes for empty values, but they also use double-quotes to escape quotes within non-empty values. This probably sounds confusing, so here's an example:

"column 1","column 2","","column 4 value is ""sort of"" like this"

The ADF pipeline failed because the double-quotes don't get escaped correctly:
ErrorCode=UserErrorSourceDataContainsMoreColumnsThanDefined, found more columns than expected column count.

The solution was to change the "Escape character" property on the dataset, by clicking the "Edit" button beneath it and manually entering "", since "" isn't in the list of escape characters.  I didn't think this would work at fir…

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…