我的帐户和关系类型(自定义实体)之间存在 N:N 关系。现在,在记录实体(另一个自定义实体)上,我有一个帐户查找,我想添加预搜索条件,以便查找可以仅显示关系类型中具有“vendor ”关系的特定实体。到目前为止,我已经按照代码片段进行查找预搜索,但它显示了所有记录。我不确定我哪里做错了。有什么想法/建议吗?
function filterAccounts() {
try {
debugger;
var accountLookup = Xrm.Page.getControl("new_accountid");
if (accountLookup == null && accountLookup == 'undefined') { }
else {
accountLookup.addPreSearch(function () {
CustomFilter(accountLookup);
});
}
} catch (e) {
alert("Error: " + e.message);
}
}
function CustomFilter(accountLookup) {
try {
debugger;
var fetchXml = "<link-entity name='new_account_new_relationshiptype' from='accountid' to='accountid' visible='false' intersect='true'>" +
" <link-entity name='new_relationshiptype' from='new_relationshiptypeid' to='new_relationshiptypeid' alias='ak'>" +
" <filter type='and'>" +
" <condition attribute='new_name' operator='eq' value='Vendor' />" +
" </filter>" +
" </link-entity>" +
" </link-entity>";
accountLookup.addCustomFilter(fetchXml);
} catch (e) {
alert("Error: " + e.message);
}
}
最佳答案
您在 addCustomFilter
中指定的 FetchXML仅意味着 <filter>
-部分。使用 addCustomFilter
时无法指定链接实体.
如果您无法简化查询,只需要考虑帐户实体上的字段,则必须使用 addCustomView
而不是addCustomFilter
.
关于javascript - 在 Dynamics CRM 的帐户查找中显示特定帐户记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40361187/