CRM 2011 JS: Update Subgrid using JScript 2

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();

}