<?xml version="1.0" ?> <error xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <code>0x80041102</code> <displaytitle>Query Builder Error</displaytitle> <displaytext>No Entity</displaytext> <description>The entity with ObjectTypeCode = 10088 was not found in the MetadataCache.</description> <file>Not available</file> <line>Not available</line> <details>The entity with ObjectTypeCode = 10088 was not found in the MetadataCache.</details> <requesturl>http://MyCrmServer/CrmOrgName/_grid/cmds/dlg_exportcustomizations.aspx</requesturl> <pathAndQuery>/CMIS-UAT/_grid/cmds/dlg_exportcustomizations.aspx</pathAndQuery> <source>XML</source> <stacktrace /> </error>
The story doesn't just end here. When I tried to click "Workflows" link in my CRM's Settings area, I got the following beautiful "Query Builder Error – No Entity" CRM screen.
After a little search on Internet, I found that CRM MVP David Yack has documented this error, which pointed me to the right direction. Based on his information, I was able to fix the problem by using the following procedures.
- Launch SQL Management Studio and connect to CRM database.
- Determine which workflow is causing the problem by using the following SQL script.
SELECT * FROM WorkflowBase WHERE PrimaryEntity='10088' -- The entity code that caused the problemBy looking at the returned record and its Name column, which is the workflow's name, you should know which workflow is causing the problem, at the same time you should be able to figure out which entity is actually causing the problem. For instance, you have figured that 'new_myentity' is the culprit.
- Determine the offending entity's ObjectTypeCode by issuing the following SQL script.
SELECT ObjectTypeCode FROM MetadataSchema.Entity WHERE Name='new_myentity' -- The entity's name that caused the problemYou should now get an integer code, so that we can use next. For instance, we got a number of 10095.
- Run the following SQL script to correct the issue.
UPDATE WorkflowBase SET PrimaryEntity='10095' -- The correct entity code (The code that you got from step 3) WHERE PrimaryEntity='10088' -- The entity code that caused the problemYou should expect a few records to be updated depending on how many workflows were involved.
BE ADVISED, any direct change made to CRM database could cause potential problem to the application, make sure to have a full database backup before doing so.
The cause of the problem might be that as soon as I finished deleting old CRM entities on the UAT environment, I immediately imported the customizations. CRM server might not have actually cleaned up the metadata cache at the point of the import, which ends up the orphan workflow records in CRM database.
Hope this helps if you ever run into the same error.