The entity with name <entityName> was not found in the MetadataCache
Asked Answered
W

3

6

Following a Microsoft hands-on lab for Dynamics CRM 2011, I am attempting to add a custom view to a form that responds 'onchange' to a particular property. Here is my function to add the custom view:

function HandleOnChangeDVMInformationLookup()
{
var locAttr = Xrm.Page.data.entity.attributes.get("new_referringdvm");

if (locAttr.getValue() != null)
{
    var dvmId = locAttr.getValue()[0].id;

    var viewDisplayName = "DVM Information";
    var viewIsDefault = true;

    var fetchXml  = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="dvminformation"><attribute name="dvminformation_id"/><attribute name="dvminformation_name"/><attribute name="new_firstname"/><attribute name="new_lastname"/><filter type="and"><condition attribute="id" operator="eq"  value="' +dvmId +'"/></filter></entity></fetch>';

    var layoutXml = '<grid name="resultset" object="10001" jump="dvminformation_name" select="1" icon="1" preview="1"><row name="result" id="dvminformation_id"><cell name="dvminformation_name" width="300" /><cell name="new_firstname" width="125"/></row></grid>';

    var control = Xrm.Page.ui.controls.get("new_dvm_information");
    control.addCustomView("62e0ee43-ad05-407e-9b0b-bf1f821c710e", "dvminformation", viewDisplayName, fetchXml, layoutXml, viewIsDefault );
}
}

Upon changing the selected 'dvm' in the form and triggering this function I receive the following error:

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The entity with a name = 'dvminformation' was not found in the MetadataCache.Detail: -2147217150 The entity with a name = 'dvminformation' was not found in the MetadataCache. 2013-06-10T22:01:49.4392114Z

Is 'dvminformation' not the entity name I just defined in the XML? Am I missing a step?

Thanks.

Wyon answered 10/6, 2013 at 22:13 Comment(0)
C
5

It's unlikely that dvminformation is a real entity name. Are you sure there is an entity that exists with that name?

Open the solution and look for the entity, then check its schema name.

If its a custom entity they usually have the format of prefix_name, e.g. new_timeline, new_alert, in your case it might just be dvm_information. If dvm is your solution prefix.

Only system entity have a name without an underscore, e.g. contact, account, incident and dvminformation doesn't look like a system entity to me.

Chigoe answered 10/6, 2013 at 22:30 Comment(1)
Ah I see, I didn't realize that 'entity name' was an EXISTING entity, changed it to an existing entity and it works. No error now, but I see no data. Could you explain what type of field/control I should be adding the custom view to..(ie. how should I define 'new_dvm_information' in my form.) Thanks!Wyon
C
1

I had the same error message with the customerAddress entity. Turns out I referenced the entity as "customerAddress" (note the camel case).

But CRM wants logical names of entities and attributes in all lower case. So "customeraddress" did work.

Cloddish answered 19/7, 2016 at 10:1 Comment(0)
O
0

Check if you are connecting to correct org (web.config?) See

Outgo answered 28/4, 2017 at 1:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.