Can i access particular column of a subgrid while using online dynamics CRM?
*This post is locked for comments
Can i access particular column of a subgrid while using online dynamics CRM?
*This post is locked for comments
Yes Sure..
function dynamicallyFilterSubGrid() {
var objSubGrid = Xrm.Page.getControl("My Timesheets");
if (objSubGrid == null || objSubGrid.readyState != "complete") {
setTimeout(dynamicallyFilterSubGrid, 1000);
return;
}
else {
var start = new Date(Xrm.Page.getAttribute("new_startdate").getValue()).toISOString();
var end = new Date(Xrm.Page.getAttribute("new_enddate").getValue()).toISOString();
var FetchXml = "<fetch distinct='false' mapping='logical' aggregate='true' output-format='xml-platform' version='1.0'>" +
"<entity name='new_timesheet'>" +
"<attribute name='new_name'/>" +
"<attribute name='new_project' alias='project_name' groupby='true' />" +
"<attribute name='new_startdate'/>" +
"<attribute name='new_enddate'/>" +
"<attribute name='new_timesheetstatus'/>" +
"<attribute name='new_billablehours' alias='billable_sum' aggregate='sum' />" +
"<order descending='false' attribute='new_billablehours'/>" +
"<link-entity name='new_timesheet' from='new_timesheetsid' to='new_billingid' alias='billing'>"+
"<filter type='and'>" +
"<condition attribute='new_startdate' value='" + start + "' operator='ge'/>" +
"<condition attribute='new_enddate' value='" + end + "' operator='le'/>" +
"</filter>" +
"</link-entity>"+
"</entity>" +
"</fetch>";
objSubGrid.control.SetParameter("fetchXml", FetchXml);
objSubGrid.control.Refresh();
}
}
Can you share the javascript code you have written?
Sir, Can i access the data using OData call and then filter it using FetchXml..Is it possible ?
Sir, for me everything is giving null
You can access subgrid as shown below.
var subGridCtrl = Xrm.Page.getControl("SubgridName");
But the problem is that in order to do filtering of rows, you should use the code below which is unsupported.
var subGridCtrl = window.parent.document.getElementById("SubgridName");
See: nishantrana.me/.../unsupported-filtering-of-subgrids-in-dynamics-365-crm-2016
So, instead of this,how do we access subgrid then?
By the line above, you are retrieving only the subgrid, not the data. Also, note that document.getElementById("Subgridname") is unsupported. lease follow the code in my above thread.
Sir, one thing more..
While retrieveing data from another entity in the current subgrid after filtering records, in the line -:
document.getElementById("Subgridname") //Current entity's subgrid or the data which we are retrieveing ?
What we use inside?
Hi,
You can write the following function with a timeout.
function AccessSubgrid() { var subGridCtrl = Xrm.Page.getControl("SubgridName"); // If subgrid is not loaded yet, then call same function after some time. if (subGridCtrl == null) { setTimeout(AccessSubgrid, 1000) return; } // Code for accessing the subgrid data once the subgrid load is completed
subGridCtrl.getGrid().getRows();
}
Hope this helps.
Thanks for the reply Sir..But the issue is while onload the subgrid is null.So it returns null..How to resolve this isssue?
André Arnaud de Cal...
292,494
Super User 2025 Season 1
Martin Dráb
231,307
Most Valuable Professional
nmaenpaa
101,156