Search code examples
powerappspowerapps-modeldriven

Pass Model Driven App Main Grid reference to Java Script on Click of a Custom Button


I am trying to get a reference to my Model Driven App Main Grid through a Java Script written on a new command of the Main Grid command bar. "SelectedControl" is the parameter I am passing to Java Script. I got the below code for this.

function ExportWithLogos(gridContext){
    var grid = gridContext.getGrid();
    var fetchXMLStr = gridContext.getFetchXML();
    console.log(fetchXMLStr);
}

Here is the Custom Command Configuration Custom Command Configuration

Somehow it doesn't work and throws the error gridContext.getFetchXML is not a function. What's wrong here?

Mentioned in the details already.


Solution

  • I believe the main issue in your script is the casing of the method. It should be getFetchXml instead of getFetchXML. You can find more information here - https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/grids/gridcontrol/getfetchxml