---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: Extend
nav: wcp_docs
parent_url: /wcp_docs/
title: WQL Query Components
layout: subsection
---

## Overview

A WQL Query component contains a query that reads data using the [Concept: Workday Query Language (WQL)](/wcp_docs/GUID-6546152a-bcf0-447d-8d64-230f9e2ac291-enHYPHENus.html). Use WQL Query components to:

-   Simplify inbound endpoints that submit complex WQL API queries.
-   Easily pass query parameters.
-   Reuse WQL queries across multiple PMDs.


To create a WQL Query component in App Builder, select <b>Queries</b> &gt; <b>WQL Queries</b> in the <b>Components</b> panel on the left.

To use a WQL Query component in a WQL inbound endpoint on a page, specify the `id` of the WQL Query component with either the WQL `GET /data` or `POST /data` endpoint.

Notes:

-   We automatically URL-encode the WQL query string when we send the WQL endpoint to the tenant. When you use WQL Query components or the `wqlQuery` attribute, you no longer need to call the `string:urlEncode` function with the WQL query string.
-   You can ask Developer Copilot to generate WQL queries for your Extend app. See [Generate Components with Developer Copilot for Extend Apps](/wcp_docs/GUID-a1cdce13-30d3-4b93-9802-ab26325a17f3-enHYPHENus.html). Note that Developer Copilot currently doesn’t support generating WQL query components with parameters.
-   Currently, you can only open a WQL Query component in Code mode.


## <a id="section_1"></a>Examples

<b>WQL Query component</b>

This sample WQL Query component contains parameters that are passed from a page inbound endpoint. The parameters are referenced in the `query`, `limit`, and `offset` properties.

```
{
  "id": "getWorkersHiredAfter",
  "parameters": ["locationId", "hireDate", "offsetParam", "limitParam"],
  "query": "
      SELECT worker, businessTitle, employeeID, hireDate
      FROM workersForHCMReporting(dataSourceFilter=allActiveWorkers)
      WHERE location in ("<% locationId %>") and hireDate >= "<% hireDate %>"
  ",
  "offset": ""<% offsetParam %>"",
  "limit": ""<% limitParam %>""
}
```

<b>Inbound endpoint using WQL Query component</b>

This sample page inbound endpoint calls the GET /data WQL endpoint, which returns paginated data to be displayed in a grid. This endpoint specifies the ID of the sample WQL Query component, <i>getWorkersHiredAfter</i>. In this example, the `offsetParam` and `limitParam` parameters use corresponding `pagingVariables` that are used with the `pagingInfo` attribute of a grid.

In Visual mode (<b>Page Load</b> tab > <b>WQL Endpoint</b>):

<table><thead><tr><th>Name</th><th>getWorkersHiredAfter</th></tr></thead><tbody><tr><td>HTTP Method</td><td>GET</td></tr><tr><td>Base URL Type</td><td>workday-wql</td></tr><tr><td>URL</td><td>data</td></tr><tr><td>Query ID</td><td>getOfficeWorkersHiredAfter</td></tr><tr><td>Parameters (Scripted values)</td><td><p>locationId: pageVariables.locationId</p> <p>hireDate: pageVariables.hireDate</p> <p>offsetParam: pagingVariables.offset ?? 0</p> <p>limitParam: pagingVariables.limit ?? 50</p></td></tr></tbody></table><br/>

In Code mode:

```
"endPoints" : [
  {
    "baseUrlType": "workday-wql",
    "name": "getWorkersHiredAfter",
    "url": "data",
    "wqlQuery": {
      queryId": "getOfficeWorkersHiredAfter",
      "parameters": {
        "locationId": "<% pageVariables.locationId %>",
        "hireDate": "<% pageVariables.hireDate %>",
        "offsetParam": "<% pagingVariables.offset ?? 0 %>",
        "limitParam": "<% pagingVariables.limit ?? 50 %>"
      }
    }
  }
]
```

Alternatively, you can embed the query in the inbound endpoint, instead of referencing a WQL Query component. This example specifies the `query` attribute inside `wqlQuery`.

```
endPoints" : [
  {
    "baseUrlType": "workday - wql",
    "name": "getOfficeWorkersHiredAfter",
    "url": "data",
    "wqlQuery": {
      "query": "
          SELECT worker, businessTitle, employeeID, hireDate
          FROM workersForHCMReporting(dataSourceFilter = allActiveWorkers)
          WHERE location in ( <% pageVariables.locationId %> ) and hireDate >= <% pageVariables.hireDate %>"
      ",
      "offset ": " "<% pagingVariables.offset ?? 0 %>" ",
      "limit": " "<% pagingVariables.limit ?? 50 %>" "
    }
  }
]
```

The example assumes that the AMD `dataProviders[]` contains:

```
{
  "key": "workday-wql",
  "value": "https://api.workday.com/wql/v1/",
}
```

## <a id="section_wQLQueryComponent"></a>WQL Query Component Attributes

-   <b>id</b>

    Data type: string (Required) The unique ID of the WQL Query component. The `id` must match the `queryId` of the PMD endpoint that references this WQL Query component.

-   <b>query</b>

    Data type: stringScript (Required) A string containing the query that uses the Workday Query Language syntax. The `query` string can contain WQL query parameters (enclosed in the `<% %>` notation). The query string has a maximum of 2048 characters.

-   <b>parameters</b>

    Data type: List of strings An unordered list of parameter names. Use `parameters` to send dynamic values from PMD endpoint definitions to the `query` within the WQL Query component. To reference a parameter in the `query`, use the PMD Scripting notation `<% %>`.

-   <b>limit</b>

    Data type: numberScript The maximum number of objects in a single response. The maximum is 10,000.

-   <b>offset</b>

    Data type: numberScript The zero-based index of the first object in a response collection. The default is 0. Use offset with the limit parameter to control paging of a response collection.

    Example: If limit is 5 and offset is 9, the response returns a collection of 5 objects starting with the 10th object.



## <a id="section_wqlQueryAttributes"></a>Inbound Endpoint wqlQuery Attributes

-   <a id="d420e114"></a><b>wqlQuery</b>

    Data type: Map

    Contains the query for the WQL `GET /data` or `POST /data` endpoint. Specify either `query` for an inline query or `queryId` to reference a WQL Query component. The `query` and `queryId` properties are mutually exclusive.

    `wqlQuery` properties:

    -   <b>query</b>

        A string script containing the WQL query. The query string can contain PMD script variables (enclosed in the `<% %>` notation). To embed a literal string inside the query, use escaped double quotes.

    -   <b>queryId</b>

        A static string containing the ID of the WQL Query component. The queryId must match the id of the WQL Query component.

    -   <b>parameters</b>

        An optional property used with queryId containing a map of parameters sent to the WQL Query component, where:

        -   key A static string containing the parameter name, which should match the name in parameters inside the WQL Query component.
        -   value An object containing the parameter value, which can be a script or any value including a boolean, string, number, native JSON map or native JSON array.

        <b>Note:</b> WQL Query components are self-contained modules and don’t have page context. Use the parameters to send any app or page-specific variables.

    -   <b>limit</b>

        An optional property used with `query`. The `limit` property specifies the maximum number of objects in a single response. The maximum is 10,000.

    -   <b>offset</b>

        An optional property used with `query`. The `offset` property specifies the zero-based index of the first object in a response collection. The default is 0. Use offset with the limit parameter to control paging of a response collection.




