or
LoadSubGrid : function () {
var entityId= Xrm.Page.data.entity.getId();
var new_lookupattribute = Xrm.Page.getAttribute("new_lookupattribute").getValue();
var new_lookupattributeId = null;
if ( new_lookupattribute ) {
new_lookupattributeId = new_lookupattribute [0].id;
}
var fetchXml = "<fetch version=\"1.0\" output-format=\"xml-platform\" mapping=\"logical\" distinct=\"false\">";
fetchXml = fetchXml + "<entity name=\"new_entity\">";
fetchXml = fetchXml + "<attribute name=\"new_attribute1\" />";
fetchXml = fetchXml + "<attribute name=\" new_attribute2\" />";
fetchXml = fetchXml + "<attribute name=\" new_attribute3\" />";
fetchXml = fetchXml + "<link-entity name=\"new_entity2\" from=\"new_entityid\" to=\"new_entity2id\" visible=\"false\" link-type=\"outer\" alias=\"a_1ee52836f351e11198888asasd450361\">";
fetchXml = fetchXml + "<attribute name=\"new_entity2attribute\" />";
fetchXml = fetchXml + "</link-entity>";
fetchXml = fetchXml + "<filter type=\"and\">";
fetchXml = fetchXml + "<condition attribute=\"new_attriubteid\" operator=\"eq\" uiname=\"ds32\" uitype=\"new_entity3\" value=\"" + entityId + "\" />";
if ( new_lookupattributeId) {
fetchXml = fetchXml + "<condition attribute=\"new_entity4id\" operator=\"eq\" uiname=\"entity4\" uitype=\"new_Entity4\" value=\"" + new_lookupattributeId + "\" />";
}
fetchXml = fetchXml + "</filter>";
fetchXml = fetchXml + "</entity>";
fetchXml = fetchXml + "</fetch>";
PopulateGridFetchXML("LoadSubGrid()", 'SubGridName', fetchXml);
}
PopulateGridFetchXML: function (sourceFunctionName, subGrid, fetchXML) {
var updateXml = function (sourceFunctionName, subGrid, field, fetchXML) {
try {
if (Xrm.Page.getControl(subGrid)._control.get_innerControl() == null) {
setTimeout(sourceFunctionName, 1000);
return;
}
Xrm.Page.getControl(subGrid)._control.get_innerControl().setParameter(field, fetchXML);
// Refresh the grid
Xrm.Page.getControl(subGrid).refresh();
} catch (e) { }
};
// Update the fetchXml
updateXml(sourceFunctionName, subGrid, "fetchXml", fetchXML);
}
No comments:
Post a Comment