Please Use window.parent.document.getElementById("Contacts");
and make sure you set to all Record Types.
Sample Code.
function showgrid()
{
var ConnectionSubgrid = Xrm.Page.getControl("Contacts").getGrid();
if(ConnectionSubgrid==null)
{
setTimeout(function () { showgrid(); }, 2000); //if the grid hasn’t loaded run this again
return;
}
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='contact'>" +
"<attribute name='fullname' />" +
"<attribute name='telephone1' />" +
"<attribute name='contactid' />" +
"<order attribute='fullname' descending='false' />" +
"</entity>" +
"</fetch>";
//Set the fetchxml directly to subgrid
var Grid = window.parent.document.getElementById("Contacts");
if (Grid.control != null) {
Grid.control.SetParameter("fetchXml", FetchXml); //set the fetch xml to the sub grid
Grid.control.refresh(); //refresh the sub grid using the new fetch xml
} else {
setTimeout('showgrid()', 500);
}
}
No comments:
Post a Comment