Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Filtering SubGrids with Javascript on Dynamics CRM 2016?

$
0
0

Hi to everyone...

Well, i'm developing an script on MS CRM online 2016, i'm trying to use the old method with fetch and lookup field, but nothing happends... someone could gimme a clue? this is my current script to do the filtering.

What i need to do is on Cases show all the related contacts for the account field on a SubGrid...

  	
// JScript source code
 
function updateSubGrid() {  
    /*This will get the related contacts grid details and store in a variable.*/
     var relatedContacts = window.parent.document.getElementById("Contactos");
    /*Initializing the lookup field to store in an array.*/
    var lookupfield = new Array;
    /*Get the lookup field*/
    lookupfield = Xrm.Page.getAttribute("customerid").getValue();
    /*This will get the lookup field guid if there is value present in the lookup*/
    if (lookupfield != null) {
        var lookupid = lookupfield[0].id;
    }
    /*Else the function will return and no code will be executed.*/
    else {
        return;
    }
    /*This method is to ensure that grid is loaded before processing.*/
    if (relatedContacts ==null || relatedContacts.readyState != "complete"){
    /*This statement is used to wait for 2 seconds and recall the function until the grid is loaded.*/
         setTimeout('updateSubGrid()', 2000);
    return;
    }    
    /*This is the fetch xml code which will retrieve all the contacts related to the account selected for the case.*/
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
	"<entity name='contact'>"+
    "<attribute name='fullname' />"+
    "<attribute name='parentcustomerid' />"+
    "<attribute name='telephone1' />"+
    "<attribute name='emailaddress1' />"+
    "<attribute name='jobtitle' />"+
    "<attribute name='contactid' />"+
    "<order attribute='fullname' descending='false' />"+
    "<link-entity name='account' from='accountid' to='parentcustomerid' alias='customer'>"+
    "<filter type='and'>"+
    "<condition attribute='parentcustomerid' operator='eq' uiname='Order Name' uitype='account' value='" + lookupid + "' />"+
    "</filter>"+
    "</link-entity>"+
    "</entity>"+
    "</fetch>";
    /*Setting the fetch xml to the sub grid.*/
    relatedContacts.control.setParameter("fetchXml", fetchXml);
    /*This statement will refresh the sub grid after making all modifications.*/
    relatedContacts.control.refresh(); 
 }  
	

Thanks for any response!


Viewing all articles
Browse latest Browse all 3363

Trending Articles



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