title: SubGrid fetchXML javascript refresh not displaying link-entity column
body: <p>I have a subgrid on a form, that I am trying to refresh with dynamic fetchXML depending on the form data. The fetch is refreshing the subGrid appropiately, however the link-entity columns are either not pulling the data, or the subGrid is not displaying it. Here is my javascript that is running.</p>
  
  <pre><code>    function UpdateContactSubGrid() {
      //If this method is called from the Onload, make sure the grid is loaded before proceeding
      if (document.getElementById('new_Opportunity_Contacts_SubGrid') == null) {
          //The subgrid hasn't loaded, wait 1 second and then try again 
          setTimeout(UpdateContactSubGrid, 1000);
          return;
      }    
  
      // To get the Id of the 'Contacts' subgrid
      var grid = document.getElementById('new_Opportunity_Contacts_SubGrid').control;  
  
      var fetchXML = "";
  
      // To get contract lookup from 'CustomerId' field 
      var accountLookup = getAttributeValue("customerid");
  
      if (accountLookup != null)
      {
           fetchXML = "&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'&gt;" +
           "&lt;entity name='new_affiliation'&gt;" +
            "&lt;attribute name='new_role' /&gt;" +
            "&lt;attribute name='new_contactid' /&gt;" +
            "&lt;attribute name='new_affiliationid' /&gt;" +          
             "&lt;order attribute='new_contactid' descending='false' /&gt;" +
             "&lt;filter type='and'&gt;" +
              "&lt;condition attribute='statecode' operator='eq' value='0' /&gt; " +
              "&lt;condition attribute='new_clientid' operator='eq' value='" + accountLookup[0].id + "' /&gt;" +
             "&lt;/filter&gt;" +
             "&lt;link-entity name='contact' from='contactid' to='new_contactid' alias='a_adbe31a68306e2118bc478e3b5100e8d'&gt;" +
             "&lt;attribute name='emailaddress1' /&gt;" +
               "&lt;attribute name='telephone1' /&gt;" +
               "&lt;attribute name='mobilephone' /&gt;" +            
             "&lt;/link-entity&gt;" +
           "&lt;/entity&gt;" +
         "&lt;/fetch&gt;";
  
      }
      else 
      {
          fetchXML = "&lt;fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'&gt;" +
           "&lt;entity name='new_affiliation'&gt;" +
            "&lt;attribute name='new_role' /&gt;" +
            "&lt;attribute name='new_contactid' /&gt;" +
            "&lt;attribute name='new_affiliationid' /&gt;" +          
             "&lt;order attribute='new_contactid' descending='false' /&gt;" +
             "&lt;filter type='and'&gt;" +
              "&lt;condition attribute='statecode' operator='eq' value='0' /&gt; " +
             "&lt;/filter&gt;" +
             "&lt;link-entity name='contact' from='contactid' to='new_contactid' alias='a_adbe31a68306e2118bc478e3b5100e8d'&gt;" +
             "&lt;attribute name='emailaddress1' /&gt;" +
               "&lt;attribute name='telephone1' /&gt;" +
               "&lt;attribute name='mobilephone' /&gt;" +            
             "&lt;/link-entity&gt;" +
           "&lt;/entity&gt;" +
         "&lt;/fetch&gt;";
      }
  
      if (grid.SetParameter)
          //Inject the new fetchXml
          grid.SetParameter("fetchXml", fetchXML);
      else
          grid.get_innerControl().setParameter("fetchXml", fetchXML);
  
      //Force the subgrid to refresh
      grid.refresh();
  }
  
  
  // parametrs:
  // attributeName: the name of the attribute  
  //purpose:
  //It checks the existance of the attribute on the form and then get the value of the attriute.It applies null checks.  
  function getAttributeValue(attributeName) {
      try {
          var returnValue = null;
          var attrb = Xrm.Page.getAttribute(attributeName);
          if (attrb != null) {
              {
                  var attrbValue = attrb.getValue();
                  if (attrbValue != null)
                      returnValue = attrbValue;
              }
          }
          return returnValue;
      }
      catch (ex) {
          alert(ex.message + ' ' + ex.name);
      }
  }
  </code></pre>