web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Binding a subgrid with custom Fetch Xml is not working CRM 2016

(0) ShareShare
ReportReport
Posted on by

We have setup CRM 2016  with Turbo form rendering  enabled.

 

I am getting an issue with regard to existing code of  Binding a subgrid with custom fetch xml .

 

The code snippet looks like the following

var gridOpenActivity = document.getElementById("grid_openActivity");

gridOpenActivity.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid  

gridOpenActivity.control.refresh(); //refresh the sub grid using the new fetch xml

 

But the code is firing an error at SetParameter

 

 

I tried updating the code to remove the unsupported js  as shown below

 

var gridOpenActivity = Xrm.Page.getControl("grid_openActivity").getGrid().$3_1;

var gridOpenActivity = document.getElementById("grid_openActivity") || window.parent.document.getElementById("grid_openActivity");

if (gridOpenActivity) {

        grid = gridOpenActivity.control;

    }

grid.SetParameter("fetchXml", fetchXml);

 

But now I am not getting the error at SetParameter but the Result from fetch xml is not getting binded and not display the expected result.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Macoy Profile Picture
    275 on at

    Hi,

    Use this.

    //bind custom fetch to subgrid

    function bindCustomFetchToGrid(){

    var yourGrid = Xrm.Page.getControl("grid_openActivity"); //get subgrid control

    if(yourGrid == null){

    //re-runs the function call if the subgrid control hasn't been fully loaded

    setTimeout(function () {

    bindCustomFetchToGrid();

    }, 2000);

    return;

    }

    var customFetchXML = "<your fetchXml query here>";

    //Set the fetchxml directly to subgrid

    yourGrid.control.SetParameter("fetchXml", customFetchXML); //pass your fetchxml

    yourGrid.control.Refresh(); //refresh subgrid to show the fetched results

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans