Microsoft Dynamics CRM 2015 - 需要过滤子网格上的查找 我正在使用的Javascript代码:
function SetCustomLookUp() {
debugger;
lookupFieldObject = Xrm.Page.data.entity.attributes.get('account');
if (lookupFieldObject.getValue() != null) {
entityId = lookupFieldObject.getValue()[0].id;
entityName = lookupFieldObject.getValue()[0].entityType;
entityLabel = lookupFieldObject.getValue()[0].name;
}
var filterXML = [
'<filter type="and">',
'<condition attribute="parentcustomerid" value="{54BC1539-C29C-E511-80E9-3863BB2E6258}" operator="eq"/>',
'</filter>'
].join('\n');
var Subgrid = Xrm.Page.getControl("Contacts");
document.getElementById("Contacts").addEventListener("click", function () {
setTimeout(function () {
var gridControl = Xrm.Page.getControl("Contacts");
var me = gridControl.$c_0.$N_4.$Y_3;
me.addPreSearch(function () {
me.addCustomFilter(filterXML);
});
}, 2000);
});
}
错误:&#34;无法读取属性&#39; addEventListener&#39; of null&#34;
答案 0 :(得分:0)
我使用了这段代码并且你出现了错误,原因是:
子网格在绘制所有表单的末尾绘制,然后你必须在子网格绘制时添加这个偶数点击
我为此写了一个小代码:
var objSubGrid = document.getElementById("subgrid_name");
//CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait until sub grid is loaded.
// that's why we are adding a delay..
if (objSubGrid == null) {
setTimeout(functionxxx, 2000);
return;
} else {
答案 1 :(得分:0)
To Modarators - 是的,我知道建议重新输入文章中提到的所有内容,但我很确定该文章将在线提供很长时间,因此我不会重新打字,因为它没有对我有意义。