Hi, I want to display associated account in an account subgrid view, is there way to achieve that and how? Thanks
*This post is locked for comments
Hi, I want to display associated account in an account subgrid view, is there way to achieve that and how? Thanks
*This post is locked for comments
I think this code below is what you are looking for.
function subgridfilter() { //get the subgrid var objSubGrid = window.parent.document.getElementById("account_subgrid"); //CRM loads subgrid after form is loaded.. so when we are adding script on form load.. need to wait until sub grid is loaded. // that's why we are adding a delay.. var isGridLoaded = null; try { isGridLoaded = objSubGrid.control.getEntityName(); } catch (err) { setTimeout(subgridfilter, 2000); return; } if (isGridLoaded != null) { //when subgrid is loaded, get GUID var GUIDvalue = Xrm.Page.data.entity.getId(); //Create FetchXML for sub grid to filter records based on GUID var FetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + " <entity name='account'>" + " <attribute name='accountid' />" + " <attribute name='createdon' />" + " <order attribute='createdon' descending='true' />" + " <filter type='and'>" + " <condition attribute='accountid' operator='eq' value='" + GUIDvalue + "' />" + " </filter>" + " </entity>" + "</fetch>"; // Layout of subgrid. var LayoutXml = "<grid name='resultset' object='1' jump='accountid' select='1' preview='1' icon='1'>" + " <row name='result' id='accountid'>" + "<cell name='accountid' width='100' />" + "<cell name='createdon' width='150' />" + "</row>" + "</grid>"; //apply layout and filtered fetchXML objSubGrid.control.SetParameter("layoutXml", LayoutXml); objSubGrid.control.SetParameter("fetchXml", FetchXml); //Refresh grid to show filtered records only. objSubGrid.control.Refresh(); } }
You might need to tweek the FetchXML a bit as I was quickly typing this up :)
this is my idea that I can have a subgrid to display all the accounts and filter out all the accounts with current account id to get associated accounts, but we do it through it javascript? any samples?
Hi sdnd,
This thread explains it community.dynamics.com/.../145695
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156