getFetchXml (Client API reference)

Gets the FetchXML query that represents the current data, including filtered and sorted data, in the grid control.

Grid types supported

Read-only and editable grids

Syntax

var result = gridContext.getFetchXml();

Return Value

Type: String

Description: The FetchXML query.

Remarks

To get the gridContext, see Getting the grid context

Example

The following example displays the retrieved Fetch XML of the Contacts subgrid in the console:

function myFunction(executionContext) {
    var formContext = executionContext.getFormContext(); // get the form context
    var gridContext = formContext.getControl("Contacts"); // get the grid context
    var retrieveFetchXML = function () {
        var result = gridContext.getFetchXml();
        console.log(result)
    };
    gridContext.addOnLoad(retrieveFetchXML);    
}