Tuesday, January 21, 2014

CRM 2013 - System.InvalidOperationException: No default view was found for object type 10082 and query type 4

This is an UNSUPPORTED operation and may break your customization's (while installing further roll-up's). Shared just for learning purpose and not recommended to use in any CRM environment.

On an upgraded CRM 2013 environment when faced a interesting issue, when we tired to search a particular entity (say entity name is A) lookup value from any of the related records form or advanced find or preview screen it throw's 'Contact administrator Error'.

We tried to identify more details and found the below error information.

System.InvalidOperationException: No default view was found for object type 10082 and query type 4 at Microsoft.Crm.Caching.DefaultSavedQueryIdCacheLoader.LoadCacheData(SavedQueryIdCacheKey key, ExecutionContext context)
   at Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key, IOrganizationContext context)
   at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey key, IOrganizationContext context)
   at Microsoft.Crm.Caching.SavedQueryCache.LookupEntry(Int32 objectType, Int32 savedQueryType, Guid organizationId, Int32 baseLanguageId)
   at Microsoft.Crm.Caching.ViewLoader.GetView(Int32 objectType, Int32 savedQueryType)
   at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.GetQuickFindXml()
   at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.processQuickFindParameter(QueryBuilder queryBuilder)
   at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.SetupQueryBuilder(QueryBuilder queryBuilder, View view)
   at Microsoft.Crm.Application.Controls.LookupGridDataProvider.SetupQueryBuilder(QueryBuilder qb, View view)
   at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadQueryData()
   at Microsoft.Crm.Application.Platform.Grid.GridDataProviderQueryBuilder.LoadData()
   at Microsoft.Crm.Application.WebServices.LookupService.ResolveLookupItem(Int32[] typesArray, String bindingColumns, String additionalParameters, String value, Int32 position, Boolean resolveEmailAddress, String savedQueryTypeParameter, View defaultView, String[] values, Boolean sortResults)   at Microsoft.Crm.Application.WebServices.LookupService.RetrieveItem(Int32[] typesArray, String bindingColumns, String additionalParameters, String[] values, Int32[] positions, Boolean resolveEmailAddress, String savedQueryTypeParameter, String defaultViewId, Nullable`1 defaultViewType, String defaultViewFetchXml, String defaultViewLayoutXml, String[] guidValues, Boolean sortResults) ---> No default view was found for object type 10082 and query type 4

We noticed the error message 'No default view was found for object type 10082 and query type 4' and tired to analyse and it step by step. Below are the points we jotted down.
  • Query Type 4 stands for 'Quick Find View'.
  • Object Type Code 10082 is our Custom entity 'A'.
  • 'No default view was found' message specifies that CRM system is not able to pull view details even though default view (public) was available for that entity.

We were not sure at the time of searching why CRM is trying to pull default view details rather than Quick find view details. As a trial and error message we tried to set the 'Quick View' as default view from the entity customization, but as expected it throw  the below error.


Then we had a doubt that this validation is only a client side validation and decided to set 'Quick Find' view as default view via SDK code. Below is the SDK code we used to set it as default view, and as expected it successfully updated.


Below are the things we identified after the updating the 'Quick Find View' as default view. 
  • In SavedQuery table Quick Find View's 'isdefault' field is set to true, but in the UI it doesn't show any indication.
  • Existing default public view 'isdefault' is still set to true in the database as well in the reflected the same in the CRM UI. 
  • And finally the lookup search started to work from everywhere :)
We applied this fix in our other environments to double check and thinks were working fine in those environment too.

Note: This is an identified bug in CRM 2013 and reported to Microsoft. We can expect the fix for the same in the coming Rollup's

No comments:

Post a Comment