locked
Filtering sub grid record based on lookUp value in Microsoft Dynamics CRM 2011. RRS feed

  • Question

  • Giving Error :- 
    Line: 1
    Error: 'UpdateSubGrid' is undefined

    This is the function i am using to filter subgrid. It was working proper before upgrade rollup12. 

    function funName_onload()
    {    
        var grid = document.getElementById('LeadActivity');
        if (grid ==null)
        {
          setTimeout('UpdateSubGrid()', 2000);
        }
        else {
              var lookupfield = new Array;
              lookupfield = Xrm.Page.getAttribute("originatingleadid").getValue();
              if (lookupfield != null) {
                 var lookupid = lookupfield[0].id;
                 }        
              else {
                   return;
                   }
             var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
             fetchXml += "<entity name='activitypointer'>";
             fetchXml += "<attribute name='regardingobjectid' />";        
             fetchXml += "<filter type='and'>";
             fetchXml += "<condition attribute='regardingobjectid' operator='eq' value='" + lookupid + "' />";
             fetchXml += "</filter>";       
             fetchXml += "</entity>";
             fetchXml += "</fetch>";

             grid.control.SetParameter("fetchXml", fetchXml);
             grid.control.Refresh();
            }
    }

    Saturday, October 5, 2013 8:52 AM

Answers

  • function funName_onload()
     {    
         var grid = document.getElementById('LeadActivity');
         if (grid ==null)
         {
           setTimeout('funName_onload()', 2000);
         }
         else {
               var lookupfield = new Array;
               lookupfield = Xrm.Page.getAttribute("originatingleadid").getValue();
               if (lookupfield != null) {
                  var lookupid = lookupfield[0].id;
                  }        
               else {
                    return;
                    }
              var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
              fetchXml += "<entity name='activitypointer'>";
              fetchXml += "<attribute name='regardingobjectid' />";        
              fetchXml += "<filter type='and'>";
              fetchXml += "<condition attribute='regardingobjectid' operator='eq' value='" + lookupid + "' />";
              fetchXml += "</filter>";       
              fetchXml += "</entity>";
              fetchXml += "</fetch>";
    
              grid.control.SetParameter("fetchXml", fetchXml);
              grid.control.Refresh();
             }
     }

    Hi Suresh,

    I think your function name is not quite correct, as per the error message 'UpdateSubGrid' is undefined, you may need to change your UpdateSubGrid  to funName_onload in your code so that when your grid is not ready, it would wait then call itself again.


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    • Unmarked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    Saturday, October 5, 2013 10:07 AM
  • Check your subgrid Data Source settings, use All Record Types. In this example, I am using Open Activities as the default view but you can use which ever suites your needs.


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    Saturday, October 5, 2013 10:39 AM

All replies

  • function funName_onload()
     {    
         var grid = document.getElementById('LeadActivity');
         if (grid ==null)
         {
           setTimeout('funName_onload()', 2000);
         }
         else {
               var lookupfield = new Array;
               lookupfield = Xrm.Page.getAttribute("originatingleadid").getValue();
               if (lookupfield != null) {
                  var lookupid = lookupfield[0].id;
                  }        
               else {
                    return;
                    }
              var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
              fetchXml += "<entity name='activitypointer'>";
              fetchXml += "<attribute name='regardingobjectid' />";        
              fetchXml += "<filter type='and'>";
              fetchXml += "<condition attribute='regardingobjectid' operator='eq' value='" + lookupid + "' />";
              fetchXml += "</filter>";       
              fetchXml += "</entity>";
              fetchXml += "</fetch>";
    
              grid.control.SetParameter("fetchXml", fetchXml);
              grid.control.Refresh();
             }
     }

    Hi Suresh,

    I think your function name is not quite correct, as per the error message 'UpdateSubGrid' is undefined, you may need to change your UpdateSubGrid  to funName_onload in your code so that when your grid is not ready, it would wait then call itself again.


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    • Unmarked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    Saturday, October 5, 2013 10:07 AM
  • Hi Eric,

    Thanks, your replay help me to came out of the error, but it dose not show me filtered activities in subgrid.

    Even I checked fetchxml it is giving me correct records.



    Saturday, October 5, 2013 10:28 AM
  • Check your subgrid Data Source settings, use All Record Types. In this example, I am using Open Activities as the default view but you can use which ever suites your needs.


    Eric UNG [Senior Analyst Programmer :: Sydney, Australia]

    • Marked as answer by Suresh Sorde Saturday, October 5, 2013 10:43 AM
    Saturday, October 5, 2013 10:39 AM
  • Yes, Its working. Thank you Eric

    Suresh Sorde

    Saturday, October 5, 2013 10:43 AM