Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Sub Grid Issue with data loading using JavaScript

$
0
0

HI,

I am trying to load sub grid data based on lookup selecting but its not loading data in sub grid.

function filterSubGrid(subgridName, fetchXml, attempts) {
   
    if (attempts < 0) { return; }

    var crmWindow = parent.Xrm.Internal.isTurboForm() ? parent.window : window;

    // Get the subgrid element to filter
    var subgrid = crmWindow.document.getElementById(subgridName);
    if (subgrid == null || subgrid.control == null) {
      
        setTimeout(function () { filterSubGrid(subgridName, fetchXml, (attempts || 10) - 1); }, 500);
        return;
    }

  
    subgrid.control.SetParameter("fetchXml", fetchXml);
    subgrid.control.refresh();
}


function filterAccountGrid() {
	
	
	var lookupObj = Xrm.Page.getAttribute("aah_sectionidid"); //Check for Lookup Object
	if (lookupObj != null) {
	var lookupObjValue = lookupObj.getValue();//Check for Lookup Value
	if (lookupObjValue != null) {
	var lookupEntityType = lookupObjValue[0].entityType, //To get EntityName
	lookupRecordGuid = lookupObjValue[0].id, // To get record GUID
	lookupRecordName = lookupObjValue[0].name; //To get record 
	
var fetchXml = 	 '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">  '  + 
 '     <entity name="aah_question">  '  + 
 '       <attribute name="aah_questionid" />  '  + 
 '       <attribute name="aah_name" />  '  + 
 '       <attribute name="createdon" />  '  + 
 '       <order attribute="aah_name" descending="false" />  '  + 
 '       <filter type="and">  '  + 
 '         <condition attribute="aah_sectionid" operator="eq"  uiname='+'"'+ lookupRecordName +'"'+'  uitype="aah_section" value="'+ lookupRecordGuid +'" />'   + 
 '       </filter>  '  + 
 '     </entity>  '  + 
 '  </fetch>  ' ; 

     filterSubGrid("Questions", fetchXml);
  

}
	}
}

xml output is like 

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">       <entity name="aah_question">         <attribute name="aah_questionid" />         <attribute name="aah_name" />         <attribute name="createdon" />         <order attribute="aah_name" descending="false" />         <filter type="and">           <condition attribute="aah_sectionid" operator="eq"  uiname="General Health"  uitype="aah_section" value="{3FFBE419-C066-E911-A975-000D3AF06B36}" />       </filter>       </entity>    </fetch>  


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>