---
schema_version: "1"
id: 9de1147bb73ca88e201c153c083ca203787971b881da370607a9efcb7e94be11
title: Retrieve
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/guides/mc-programmatic-content/ssjs_queryDefinitionRetrieve.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_queryDefinitionRetrieve.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 60a09c647d95028fd95718123cc7649b776e84b31828af18efe4ad7d19adc3ab
products:
  - Marketing Cloud Engagement APIs and Programmatic Languages
  - Marketing Cloud
---
# Retrieve

Retrieve query definitions that match a set of search criteria.

## Syntax

```
Retrieve(1)
```

## Properties

| Ordinal | Type        | Description                                            |
| ------- | ----------- | ------------------------------------------------------ |
| `1`     | JSON object | Required. A JSON object that contains search criteria. |

### JSON Object Structure for a Basic Search

A simple search contains a single criterion. To perform a simple search, pass a JSON object that contains a [Property](#property), a [SimpleOperator](#simpleoperator), and a [Value](#value). In some cases, such as when you search for a null value, you can omit the `Value`.

For example, a simple search can return all query definitions that were modified between January 1, 2025 and February 1, 2025, as shown in this code sample.

```js
{
  Property: "ModifiedDate",
  SimpleOperator: "between",
  Value: ["2025-01-01T00:00:00.000","2025-02-01T00:00:00.000"]
}
```

### JSON Object Structure for a Complex Search

A complex search contains two criteria that are connected with AND or OR logic. To perform a complex search, pass a JSON object that contains a `LeftOperand` object, a `LogicalOperator`, and a `RightOperand` object.

The `LeftOperand` and `RightOperand` objects both contain the same content: a Property, a SimpleOperator, and a Value.

The value of `LogicalOperator` is either `AND` or `OR`, depending on the type of logic that you want to use to connect the two operands.

This sample shows a complex search that returns active query definitions where the name of the query definition begins with the phrase "LoyaltyRewards."

```js
{
  LeftOperand: {
    Property: "Status",
    SimpleOperator: "equals",
    Value: "Active"
  },
  LogicalOperator: "AND",
  RightOperand: {
    Property: "Name",
    SimpleOperator: "like",
    Value: "LoyaltyRewards%"
  }
}
```

## Property

The `Property` contains the name of the field to perform the search in. For example, to search for query definitions based on their name, specify `Name`. This table lists several common properties.

| Property       | Type     | Description                                                    |
| -------------- | -------- | -------------------------------------------------------------- |
| `Name`         | String   | The name of the query definition.                              |
| `ObjectID`     | String   | A unique ID for the query definition.                          |
| `QueryText`    | String   | The SQL expression used in the query definition.               |
| `TargetType`   | String   | The type of object that the query definition targets.          |
| `Status`       | String   | The status of the query definition.                            |
| `Description`  | String   | The optional description of the query definition.              |
| `CreatedDate`  | Datetime | The date and time when the query definition was created.       |
| `ModifiedDate` | Datetime | The date and time when the query definition was last modified. |
| `CustomerKey`  | String   | An external identifier for the query definition.               |

## SimpleOperator

For the `SimpleOperator` property, specify the comparison that you want to perform between the `Property` and the `Value`. This table lists the comparisons that you can perform.

| Operator             | Description                                                                                                                                                                                        |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `between`            | Search for a value that’s between two specified values. For example, `ID BETWEEN ["123456","987654"]` searches for all ID values greater than or equal to 123456 and less than or equal to 987654. |
| `equals`             | Search for an exact match.                                                                                                                                                                         |
| `greaterThan`        | Search for a numeric value that’s greater than the specified value.                                                                                                                                |
| `greaterThanOrEqual` | Search for a numeric value that’s greater than or equal to the specified value.                                                                                                                    |
| `in`                 | Search for any of the values in a list that contains multiple values. For example `ID IN {"123456","234567","345678"}` searches for any ID values that are exactly 123456, 234567, or 345678.      |
| `isNotNull`          | Search for any non-null value.                                                                                                                                                                     |
| `isNull`             | Search for null values.                                                                                                                                                                            |
| `lessThan`           | Search for a numeric value that’s less than the specified value.                                                                                                                                   |
| `lessThanOrEqual`    | Search for a numeric value that’s less than or equal to the specified value.                                                                                                                       |
| `like`               | Search for a string that matches a specified pattern. This operator supports all Transact-SQL wildcard operators.                                                                                  |
| `notEquals`          | Search for any value that doesn’t exactly match the specified value.                                                                                                                               |

## Value

For the `Value` property, specify the value that you want to search for. You can omit the `Value` property if the value of the `SimpleOperator` property is `isNull` or `isNotNull`.

## Usage

This sample code retrieves all active query definitions.

```js
<script runat="server">
  Platform.Load("Core","1");

  try {
    var result = QueryDefinition.Retrieve({
        Property:"Status",
        SimpleOperator:"equals",
        Value:"Active"
    });

    Write(Stringify(result));
  } catch (e) {
    Write(Stringify(e));
  };
</script>
```

The response is an array of objects. Each object in the array represents a query definition that meets the search criteria.

```json
[
  {
    "Name": "Staging_Clear",
    "ObjectID": "1510cbd5-0d53-4259-a1c1-99dc7654be09",
    "QueryText": "select 'w@w.com' as [Email], 'test' as [Link], 'test' as [Version], 'test' as [Product] where 1 = 2",
    "TargetType": "DE",
    "DataExtensionTarget": {
      "Name": "Staging",
      "Description": "Used to store data for send",
      "Keyword": null,
      "Client": null,
      "PartnerKey": null,
      "PartnerProperties": null,
      "CreatedDate": "0001-01-01T00:00:00.000",
      "CreatedDateSpecified": false,
      "ModifiedDate": null,
      "ModifiedDateSpecified": false,
      "ID": 0,
      "IDSpecified": false,
      "ObjectID": null,
      "CustomerKey": "Staging",
      "Owner": null,
      "CorrelationID": null,
      "ObjectState": null,
      "IsPlatformObject": false,
      "IsPlatformObjectSpecified": false
    },
    "TargetUpdateType": "Overwrite",
    "FileSpec": "",
    "FileType": "",
    "Status": "Active",
    "CategoryID": 0,
    "CategoryIDSpecified": false,
    "InteractionObjectID": null,
    "Description": "Clears the Staging DE after a send",
    "Keyword": null,
    "Client": null,
    "PartnerKey": null,
    "PartnerProperties": null,
    "CreatedDate": "2011-12-20T08:02:17.437",
    "CreatedDateSpecified": true,
    "ModifiedDate": "2011-12-20T08:02:17.437",
    "ModifiedDateSpecified": true,
    "ID": 0,
    "IDSpecified": false,
    "CustomerKey": "Staging_Clear",
    "Owner": null,
    "CorrelationID": null,
    "ObjectState": null,
    "IsPlatformObject": false,
    "IsPlatformObjectSpecified": false
  }
]
```
