簡體   English   中英

Microsoft Dynamics CRM 2015 –需要具有子網格查找篩選器

[英]Microsoft Dynamics CRM 2015 – Need to have Subgrid Lookup Filter

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);
    });
}

錯誤:“無法讀取null的屬性'addEventListener'”

我使用了此代碼,並且錯誤顯示了您的原因,原因是:

子網格在繪制所有窗體的末尾進行繪制,然后,當子網格在繪制時,即使單擊也必須添加此子網格

我為此編寫了一個小代碼:

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 {

以下文章包含答案-http: //www.magnetismsolutions.com/blog/paulnieuwelaar/2016/06/20/filter-nn-add-existing-lookup-dynamics-crm-2016-turbo-forms

致Modarators-是的,我知道建議重新鍵入文章中提到的所有內容,但我很確定該文章將在網上長期存在,因此我不會再次鍵入,因為這對我來說毫無意義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM