Dynamics CRM 2015 Online: SubGrid's control.SetParameter method is not available

泪湿孤枕 提交于 2019-12-04 19:26:21
A.K

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!