最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dynamics CRM 2015 Online: SubGrid's control.SetParameter method is not available - Stack Overflow

programmeradmin1浏览0评论

I'm trying to populate a subgrid with fetchXml results in CRM 2015 online. One issue in the beginning was that document.getElementById("leadUmbrellaGrid"); returns null

function filterSubGrid() {

    var leadwithSameNameGrid = Xrm.Page.getControl("leadUmbrellaGrid").getGrid();//HAVE TRIED window.parent.document.getElementById("leadUmbrellaGrid"); //grid to filter
    var currentleadId = Xrm.Page.data.entity.getId();;
    if (leadwithSameNameGrid == null) {

        setTimeout('filterSubGrid()', 500);
        return;
    }
    //fetch xml code 
    var fetchXml = "<fetchxml goes here>";


    leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
    leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml

}

I have gone through this and this

I tried window.parent.document.getElementById as well but in both cases, the .control is null or undefined and end up with:

TypeError: Unable to get property 'SetParameter' of undefined or null reference

Would appreciate your help/tips. Thanks,

I'm trying to populate a subgrid with fetchXml results in CRM 2015 online. One issue in the beginning was that document.getElementById("leadUmbrellaGrid"); returns null

function filterSubGrid() {

    var leadwithSameNameGrid = Xrm.Page.getControl("leadUmbrellaGrid").getGrid();//HAVE TRIED window.parent.document.getElementById("leadUmbrellaGrid"); //grid to filter
    var currentleadId = Xrm.Page.data.entity.getId();;
    if (leadwithSameNameGrid == null) {

        setTimeout('filterSubGrid()', 500);
        return;
    }
    //fetch xml code 
    var fetchXml = "<fetchxml goes here>";


    leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
    leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml

}

I have gone through this and this

I tried window.parent.document.getElementById as well but in both cases, the .control is null or undefined and end up with:

TypeError: Unable to get property 'SetParameter' of undefined or null reference

Would appreciate your help/tips. Thanks,

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Sep 14, 2015 at 12:01 A.KA.K 5051 gold badge12 silver badges31 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

Here's the solution:

  1. We need to use window.parent.document.getElementById

  2. Wait for the control to load in the DOM.

So the code would look like this:

function filterSubGrid() 
{

    var leadwithSameNameGrid = window.parent.document.getElementById("leadUmbrellaGrid");
    var currentleadId = Xrm.Page.data.entity.getId();;
    if (leadwithSameNameGrid == null) 
    {
        setTimeout(filterSubGrid, 500);
        return;
    }

    //fetch xml code 
    var fetchXml = "<fetchxml goes here>";
    if (leadwithSameNameGrid.control != null) 
    {
        leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
        leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml
    } 
    else 
    {
        setTimeout(filterSubGrid, 500);
    }
}
function filterSubGrid() {

        var leadwithSameNameGrid = window.parent.document.getElementById("leadUmbrellaGrid");
        var currentleadId = Xrm.Page.data.entity.getId();;
        if (leadwithSameNameGrid == null) {

            setTimeout('filterSubGrid()', 500);
            return;
        }
        //fetch xml code 
        var fetchXml = "<fetchxml goes here>";
        if (relatedProjectsSubGrid.control != null) {
        leadwithSameNameGrid.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid   
        leadwithSameNameGrid.control.refresh(); //refresh the sub grid using the new fetch xml
          } else {
        setTimeout('filterSubGrid()', 500);
        }

    }

Ive tried this one but didn't quite get where did you get the "relatedProjectsSubGrid.control", also is this still working for CRM 7.1? Thanks

发布评论

评论列表(0)

  1. 暂无评论