Change the Fetch XML and set the subgrid ID
function UpdateSubGrid()
{
var leadGrid = document.getElementById("Contact");//Set Subgrid ID
//If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding
if (leadGrid.readyState != "complete")
{
//The subgrid hasn't loaded, wait 1 second and then try again
setTimeout('UpdateLeadSubGrid()', 1000);
return;
}
var fetchXml = "
//Inject the new fetchXml
leadGrid.control.setParameter("fetchXml", fetchXml);
//Force the subgrid to refresh
leadGrid.control.refresh();
}
Does this work anymore? I have added this code for CRM 2011 on-prem, but it doesnt work for me
ReplyDeleteya. This work for me.
ReplyDeleteThis is my Code.Set Grid Id Correct.
function UpdateSubGrid() {
var leadGrid = document.getElementById("Contact");
//If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding
if (leadGrid.readyState != "complete") {
//The subgrid hasn't loaded, wait 1 second and then try again
setTimeout('UpdateLeadSubGrid()', 1000);
return;
}
var accID = Xrm.Page.data.entity.getId();
// alert(accID);
var fetchXml = ""
+ " "
+ " "
+ " "
+ " "
+" "
+" "
+ " "
+ ""
+" "
+ " "
+ " "
+" ";
// alert(fetchXml);
//Inject the new fetchXml
leadGrid.control.setParameter("fetchXml", fetchXml);
//Force the subgrid to refresh
leadGrid.control.refresh();
}
Sorry My Fetch IS
ReplyDelete"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"
+ " <entity name='contact'>"
+ " <attribute name='contactid' />"
+ " <attribute name='mship_fullname' />"
+ " <attribute name='fia_isnominatedrepresentative' />"
+" <link-entity name='fia_membercontact' from='fia_contactid' to='contactid' >"
+" <filter type='and'>"
+ " <condition attribute='fia_memberid' operator='eq' value='" + accID + "' />"
+ "<condition attribute='statuscode' operator='eq' value='1' uiname='' uitype='' />"
+" </filter>"
+ " </link-entity>"
+ " <order attribute='fia_isnominatedrepresentative' descending='false' />"
+" </entity></fetch>";
Hi, I cant get this to work. Can you help? My code is:
ReplyDeletefunction UpdateSubGrid() {
var leadGrid = document.getElementById("Test");
//If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding
if (leadGrid.readyState != "complete") {
//The subgrid hasn't loaded, wait 1 second and then try again
setTimeout('UpdateSubGrid()', 1000);
return;
}
//Update the fetchXML that will be used by the grid.
var fetchXml = ""
+ ""
+ " "
+ ""
+ ""
+ ""
+ " "
+ " "
+ " "
+ " "
+ ""
+ "";
alert(fetchXml);
//Inject the new fetchXml
leadGrid.control.setParameter("fetchXml", fetchXml);
//Force the subgrid to refresh
leadGrid.control.refresh();
}
This doesn't work for Form Type = 1. How can i achieve this??
ReplyDeleteDoes anyone know how to update/load a sub-grid using oData instead of FetchXML?
ReplyDelete