locked
Subgrid record filter based on lookup selection in MS CRM 2011 RRS feed

  • Question

  • Hi,

    Is it possible to filter a sub grid records  based on look up values selection   in MS CRM 2011. ?

    I have a req to display records in a  sub grid  based on Date selection form the look up.

    Any Suggestion please ...

    Thanks in Advance .


    Krishn Prasad Shetty

    Thursday, September 20, 2012 8:15 AM

All replies

  • Hi,

    Please check this: http://blogs.technet.com/b/tvishnun1/archive/2012/03/11/filtering-records-in-the-sub-grid-in-microsoft-dynamics-crm-2011.aspx


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by HIMBAPModerator Thursday, September 20, 2012 9:33 AM
    Thursday, September 20, 2012 9:33 AM
    Moderator
  • Thanks for your reply..


    Krishn Prasad Shetty

    Thursday, September 20, 2012 11:06 AM
  • Hi.. Mahender ,

    I followed your link for sub grid filter based on date , here  I am getting an error like this ,

    What is the reason for this ?


    Krishn Prasad Shetty

    Monday, September 24, 2012 11:17 AM
  • Hi,

    Could you paste your fetchxml here ??


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, September 24, 2012 4:22 PM
    Moderator
  • Hi,

    This is my java script ,

    function test()
    {
     
      //debugger;

     //var grid = document.getElementById('AccountHoldings');    

      var grid =Xrm.Page.ui.controls.get('AccountHoldings')._control;  

     // if (grid ==null || grid.readyState != "complete")
     //  {
         //The subgrid hasn't loaded, wait 1 second and then try again
      //   setTimeout('test()', 1000);
      //   return;
       // }

    alert(grid);
         
      var dateid = Xrm.Page.getAttribute('cv_selectdate').getValue();   //select date fields
          
    alert(dateid);

             //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='true'>";

         fetchXml +="<entity name='cv_holdings'>";

         fetchXml += "<attribute name='cv_vehiclename' />";
     
         fetchXml += "<attribute name='cv_tradedate' />";

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

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

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

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

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

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

         fetchXml += "<order attribute='cv_vehiclename' descending='false' />";
     
         fetchXml +="<filter type='and'>";
         
          fetchXml +="<condition attribute='cv_positiondate' operator='on' value='"+ dateid + "' />";
       
          fetchXml += "</filter>";
     
          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.

        grid.control.refresh();

    }


    Krishn Prasad Shetty

    Tuesday, September 25, 2012 7:23 AM