CRM 2013 - FetchXML & the subgrid RRS feed

  • Question

  • Hi everyone,

    I need some help with my code as the implementation of applying custom FetchXml to a subgrid has appeared to have changed in CRM 2011 to CRM 2013.  Please note this is NOT the issue of setParameter vs SetParameter casing as I keep finding all over the net.  My issue is how to reference the subgrid and call the SetParameter method at all.

    Here is my code:

    function uc_addCaseFilterToCaseGrid() {
       var contactGuid = Xrm.Page.data.entity.getId();
      //create a filter xml
       if (contactGuid != null) 
              var filter = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>";
                    filter += "<entity name='uc_crecord'>";
                    filter += "<attribute name='uc_casemanager' />";
                    filter += "<attribute name='uc_cindividual' />";
                    filter += "<attribute name='uc_rindividual'/>";
    	        filter += "<filter type='or'>" +
    	   	               "<filter type='or'>" +
    	                	"<condition attribute='uc_casemanager' operator='eq' value='" + contactGuid + "'/>" +
    	                	"<condition attribute='uc_cindividual' operator='eq' value='" + contactGuid + "'/>" +
    	                	"<condition attribute='uc_rindividual' operator='eq' value='" + contactGuid + "'/>" +
    	                	"</filter>" +
    	                 "</filter>" +
                             "</entity>" +
    	    //add filter
                //var caseGrid = Xrm.Page.getControl("gPR");
               //var caseGrid = Xrm.Page.ui.controls.get("gPR");
               var caseGrid = document.getElementById("gPR").control;
                if (caseGrid == null) 
                   //The caseGrid hasn't loaded, wait 1 second and then try again     
                   setTimeout(uc_addCaseFilterToCaseGrid, 3000);

    This code does not work because the bold, italisized line is causing me a problem.  

    If I use getElementByID (not recommended, and not the approach I'd like to take) the code SetParameter executes as expected. 

    However, I want to use the following to set the variable:

    var caseGrid = Xrm.Page.getControl("gPR");

    as I want to ensure future support.  But when I call SetParameter I get an error "Object doesn't support property or method 'SetParameter'". What gives?

    I've tried the following:




    I've tried setParameter and SetParameter and both yield the same result.

    I'm going around the bend trying to figure it out - is it possible that you just can't use SetParameter anymore in CRM 2013 (but you could in 2011)?  If so, how else can I supply the fetchXml for a subgrid?

    Tested in IE11, CRM 2013 Update Rollup pack 1 + Service Pack 1. 

    Thanks for your time.

    • Edited by Annie Fisher Wednesday, January 28, 2015 2:14 AM
    Wednesday, January 28, 2015 12:48 AM

All replies

  • HI Annie

    Did you get this to work yet, you can try the following, it works for me on CRM2013 SP1 but is NOT Supported code and does not work in CRM2105 or 2015 SP1

    var SubGrid =





    Wednesday, February 17, 2016 5:16 PM