Answered by:
Deep Subgrid Query: Show other contacts that share the same Parent Customer (Account)

Question
-
I thought I'd throw this out and see if anybody can offer any help, or let me know if what I want is simply not supported within the existing "Deep Subgrid Query" functionality (http://blogs.msdn.com/b/crm/archive/2012/04/16/deep-queries-for-subgrids.aspx).
I have built a handful of these, but have never done one like I detail below:
On the Contact record, I would like to display a grid showing all contacts that share the same Parent Customer (Account). For this we can assume that only Accounts will be used as Parent Customers.
Example: Tom, Dick, and Harry work for XYZ company. Opening Tom's record would show a grid with Tom, Dick, and Harry in it.
Is this possible?
Thanks in advance,
-James
Monday, August 19, 2013 5:48 PM
Answers
-
Yes, this is possible. However you will need to use JavaScript to filter the sub-grid.
See this example, which shows a similar requirement (just change it from showing contacts to showing accounts, and filter by the parentcustomerid):
Hope that helps
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
- Marked as answer by James Reinhardt Tuesday, August 20, 2013 3:43 PM
Monday, August 19, 2013 8:56 PM -
Try this code
function UpdateSubGrid(){ var leadGrid = document.getElementById("Condensate"); //If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding //Included extra null check as a rollup 5 fix if (leadGrid ==null || leadGrid.readyState != "complete") { //The subgrid hasn't loaded, wait 1 second and then try again setTimeout('UpdateSubGrid()', 1000); return; } //Update the fetchXML that will be used by the grid. var oPack = Xrm.Page.getAttribute("new_condensateid").getValue()[0].id; var fetchXml= '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="new_pack"><attribute name="new_packid" /><attribute name="new_name" /><attribute name="createdon" /><attribute name="new_totalprice" /><attribute name="new_quantity" /><attribute name="new_listprice" /><order attribute="new_name" descending="false" /><filter type="and"><condition attribute="new_productpackid" operator="eq" value="'+oPack+'"/></filter><link-entity name="product" from="productid" to="new_productid" visible="false" link-type="outer" alias="a_7696afcf6bf0e2119c5178e3b508aaa1"><attribute name="productnumber" /></link-entity></entty></fetch>'; i // alert(fetchXml); leadGrid.control.SetParameter("fetchXml", fetchXml); //Force the subgrid to refresh leadGrid.control.Refresh(); }
after change fetchXML
Regards Faisal
- Marked as answer by James Reinhardt Tuesday, August 20, 2013 3:43 PM
Tuesday, August 20, 2013 2:08 PM
All replies
-
Yes, this is possible. However you will need to use JavaScript to filter the sub-grid.
See this example, which shows a similar requirement (just change it from showing contacts to showing accounts, and filter by the parentcustomerid):
Hope that helps
If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".
- Marked as answer by James Reinhardt Tuesday, August 20, 2013 3:43 PM
Monday, August 19, 2013 8:56 PM -
Paul-
Thanks for the info. It's exactly what I need, but is still giving me some headaches. I'm getting an error that updateSubGrid() is undefined. Are you sure that this function is still available in RU14?
Tuesday, August 20, 2013 1:47 PM -
Try this code
function UpdateSubGrid(){ var leadGrid = document.getElementById("Condensate"); //If this method is called from the form OnLoad, make sure that the grid is loaded before proceeding //Included extra null check as a rollup 5 fix if (leadGrid ==null || leadGrid.readyState != "complete") { //The subgrid hasn't loaded, wait 1 second and then try again setTimeout('UpdateSubGrid()', 1000); return; } //Update the fetchXML that will be used by the grid. var oPack = Xrm.Page.getAttribute("new_condensateid").getValue()[0].id; var fetchXml= '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="new_pack"><attribute name="new_packid" /><attribute name="new_name" /><attribute name="createdon" /><attribute name="new_totalprice" /><attribute name="new_quantity" /><attribute name="new_listprice" /><order attribute="new_name" descending="false" /><filter type="and"><condition attribute="new_productpackid" operator="eq" value="'+oPack+'"/></filter><link-entity name="product" from="productid" to="new_productid" visible="false" link-type="outer" alias="a_7696afcf6bf0e2119c5178e3b508aaa1"><attribute name="productnumber" /></link-entity></entty></fetch>'; i // alert(fetchXml); leadGrid.control.SetParameter("fetchXml", fetchXml); //Force the subgrid to refresh leadGrid.control.Refresh(); }
after change fetchXML
Regards Faisal
- Marked as answer by James Reinhardt Tuesday, August 20, 2013 3:43 PM
Tuesday, August 20, 2013 2:08 PM -
Faisal (and Paul)-
Thank you for the responses. Faisal's code gave me the additional info I needed to get this finished.
Much Appreciated!James
Tuesday, August 20, 2013 3:43 PM