Update the fetchXML that will be used by the Sub- grid in Dynamics CRM

///<reference path="XrmPage-vsdoc.js"/>
function UpdateSubGrid()
{
 window.scroll(0,0);
 var rereferralsGrid = document.getElementById("rereferrals");
 var lookupfield = new Array;
 lookupfield = Xrm.Page.getAttribute("ftd_familymember").getValue();
 intakeid = Xrm.Page.getAttribute("safy_intakeid").getValue();

 if (lookupfield != null)
 {
     var lookupid = lookupfield[0].id;
 }

else
 {
    return;
 }


if (rereferralsGrid ==null || rereferralsGrid.readyState != "complete")
{
    setTimeout('UpdateSubGrid()', 2000);
    return;
}   

 //Update the fetchXML that will be used by the grid.
 var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" 
 fetchXml += "<entity name='ftd_intakeassessment'>";
 fetchXml += "<attribute name='safy_intakeassessment'/>";
 fetchXml += "<attribute name='ftd_intakeassessmentid' />";
 fetchXml += "<attribute name='safy_intakeid' />";
 fetchXml += "<attribute name='safy_ica_status_reason' />";
 fetchXml += "<attribute name='safy_ica_status' />";
 fetchXml += "<attribute name='safy_ica_provider_worker_name' />";
 fetchXml += "<attribute name='safy_ica_name' />";
 fetchXml += "<attribute name='safy_ica_intake_office' />";
 fetchXml += "<attribute name='safy_familymembername' />";
 fetchXml += "<attribute name='safy_ica_assess_supervisor' />";
 fetchXml += "<order attribute='safy_intakeid' descending='false' />";
 fetchXml += "<filter type='and'>";
 fetchXml += "<condition attribute='safy_initialassessment' operator='eq' value='1' />";
 fetchXml += "<condition attribute='safy_intakeid' operator='ne' value='"+ intakeid +"' />"
 fetchXml += "<condition attribute='ftd_familymember' operator='eq' uiname='Family Member' uitype='ftd_familymember' value='" + lookupid + "' />";
 fetchXml += "</filter>";
 fetchXml += "</entity>";
 fetchXml += "</fetch>";

 rereferralsGrid.control.SetParameter("fetchXml", fetchXml);
 rereferralsGrid.control.refresh();
}

Comments

Popular posts from this blog

Workflow Activity Input and Output Parameters and Data Types in MS CRM 2013/15/16

Get Workflow Guid in Javascript using OData query

Convert Plugin to Sandbox mode,