Featured Post

Dynamics 365 - Business Process Flow and Things to take note before you upgrade into Dynamics 365.

In 2 months ago, my company decided to upgrade the Dynamics CRM 2016 into Dynamics 365 and there is something different about Dynamics 365 B...

Monday, October 26, 2015

Dynamics CRM 2015 - Programatically filter the Subgrid After CRM 2015 update 1

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