Filtering Subgrid by Lookup Field Dynamic Crm 2011 RRS feed

  • Question

  • Hi,

    How can i filter subgrid view according to lookup field that is on the same entity form?



    Thursday, September 13, 2012 12:23 PM

All replies

  • Hi Caner,

    If i am getting you correctly. I think this can be done through mapping in the relationship. Please elaborate the requirement in more detail.



    Thursday, September 13, 2012 12:44 PM
  • Thursday, September 13, 2012 12:55 PM
  • http://blogs.technet.com/b/tvishnun1/archive/2012/03/11/filtering-records-in-the-sub-grid-in-microsoft-dynamics-crm-2011.aspx

    here you go.

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior Solution Architect HP Australia Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com

    Thursday, September 13, 2012 12:56 PM
  •  Thanks for answers but i know this article.

     setParameter function doesn't exist in the subgrid methods.


    function updateSubGrid() {

         var grid = document.getElementById('subGrid');

         if (grid == null) {
             setTimeout('updateSubGrid()', 2000);
         else {

             var lookupfield = new Array;

             lookupfield = Xrm.Page.getAttribute("new_lookup").getValue();

             if (lookupfield != null) 

                 var lookupid = lookupfield[0].id;

             //Else the function will return and no code will be executed.

             else {


             //This method is to ensure that grid is loaded before processing.

             //This is the fetch xml code which will retrieve all the order products related to the order selected for the case.

             var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";

             fetchXml += "<entity name='activitypointer'>";  //the name of the related entitty

             fetchXml += "<attribute name='regardingobjectidname' />"; //*

             fetchXml += "<attribute name='subject' />";

             fetchXml += "<attribute name='description' />";

             //  fetchXml += "<order attribute='parentcustomerid' descending='false' />";
             // fetchXml += "<link-entity name='lead' from='parentcustomerid' to='customerid' alias='aa'>";

             fetchXml += "<filter type='and'>";

             fetchXml += "<condition attribute='regardingobjectidname' operator='eq' value='" + lookupid + "' />";

             fetchXml += "</filter>";

             fetchXml += "</link-entity>";

             fetchXml += "</entity>";

             fetchXml += "</fetch>";

             //Setting the fetch xml to the sub grid.

             grid.control.setParameter("fetchXml", fetchXml);

             //This statement will refresh the sub grid after making all modifications.



    • Edited by Caner Lenger Friday, September 14, 2012 8:50 AM code
    Friday, September 14, 2012 7:32 AM