Redigera

Dela via


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 (exeCtx) {
        var gridCtx = exeCtx.getFormContext().getControl("Contacts");
        var result = gridCtx.getFetchXml();
        console.log(result)
    };
    gridContext.addOnLoad(retrieveFetchXML);
}