在 Microsoft 的 Dynamics CRM 2011 动手实验之后,我尝试将自定义视图添加到响应“onchange”特定属性的表单中。这是我添加自定义视图的功能:
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 );
}
}
更改表单中选定的“dvm”并触发此功能后,我收到以下错误:
未处理的异常:System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault,Microsoft.Xrm.Sdk,Version=5.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35]]:名称为 'dvminformation 的实体' 在 MetadataCache 中找不到。详细信息:-2147217150 在 MetadataCache 中找不到名称为“dvminformation”的实体。2013-06-10T22:01:49.4392114Z
'dvminformation' 不是我刚刚在 XML 中定义的实体名称吗?我错过了一步吗?
谢谢。