I tried to use FetchXML through a web resource but it seems like FetchXML is not supported on sub grids in Ms dynamics 2016 update 1. Can someone please guide me in right directions? Thanks
*This post is locked for comments
Hi Dinesh, I know none of the suggestions in this post answered your question, sorry about that.
What about a different path? DId you try looking at PowerBI to really go after the data and create the charts / grids / visualizations you are looking for? PowerBI will be able to really help you filter in many different ways the information you are trying to capture and will provide great dashboards for your users to "slice and dice" the information.
Check out the following and I hope it helps Dinesh!
technet.microsoft.com/.../dn708055.aspx
Thanks,
Unfortunately, non of the above items worked for me. I do not get errors but grid refreshes and brings the same results. It does not filter by the filter criteria mentioned in fetchXML. Thanks
The column set should be ths same as the view used. Please see if below thread helps
To filter by lookupid in FectchXML, use the following code.
fetchXml += " <condition attribute='parentcustomerid' operator='eq' value='" + lookupid + "' />"
Hope it helps.
Thanks
Hi I tried the above step with no luck.. The grid refreshes but the records do not get filtered. No errors thrown in Debug mode. Below is the sample code I used. Please note <condition attribute='emailaddress1' operator='eq' value='Adrian@adventure-works.com' is used for testing purpose. My real requirement is to filter by parentcustomerid.
function dynamicallyFilterSubGrid() {
//RelatedCars : is name of subgrid given on Form.
var objSubGrid = window.parent.document.getElementById("ContactsGrid");
//CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait unitil
subgrid is loaded.
// thats why adding delay..
if (objSubGrid == null || objSubGrid.readyState != "complete") {
setTimeout(dynamicallyFilterSubGrid, 2000);
return;
}
else {
//when subgrid is loaded, get category value
// var category = Xrm.Page.getAttribute('parentcustomerid').getValue();
//Create FetchXML for sub grid to filter records based on category
var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
"<entity name='contact'>" +
"<attribute name='fullname' />" +
"<attribute name='parentcustomerid' />" +
"<attribute name='telephone1' />" +
"<attribute name='emailaddress1' />" +
"<attribute name='contactid' />" +
"<order attribute='fullname' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='statecode' operator='eq' value='0' />" +
"<condition attribute='emailaddress1' operator='eq' value='Adrian@adventure-works.com' />" +
"</filter>" +
"</entity>" +
"</fetch>";
if(objSubGrid.control != null)
{
objSubGrid.control.setParameter("fetchXml", FetchXml);
/*This statement will refresh the sub grid after making all modifications.*/
objSubGrid.control.Refresh();
}
else {
setTimeout(objSubGrid, 2000);
}
}
}
Hi,
If in case you are using any unsupported code to change Fetch Xml of the grid, then in order to allow it to work you need to set legacy form rendering to no from settings -> administration -> System setting as shown below.
We highly recommend not to do so because in future it might affect the page rendering.
Thanks!
Sam
Hi Drew, Thank you for the quick reply. My requirement is little bit more complex. I want a sub grid which shows contacts in contacts form which dynamically filtered by Account id. So when you open up contact record the subgrid will show all contacts related to the account attached to that specific contact record. When you add a standard contact subgrid (showing related records), it just shows up blank. I can have a subgrid to show all active contacts in contact form, but I will need to dynamically filter records so it will only show related records to the account. Thank you
Hi Dinesh,
Refer the links below for creating subgrids in CRM 2016 Update 1.
https://msdn.microsoft.com/en-in/library/dn932137.aspx
https://technet.microsoft.com/en-us/library/dn920679.aspx
Also refer the link below for adding a subgrid to related records in contacts.
http://blog.clickdimensions.com/2015/10/adding-a-sub-grid-of-related-records-to-your-contacts.html
https://community.dynamics.com/crm/f/117/t/155528
Hope this helps.
Thanks
Hi Dinesh,
Why do you need to use FetchXML for this type of capability? You should be able to display contacts that are related to the account through standard functionality with the subgrid. Please provide more details on the challenge here.
Thanks,
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156