Retrieve()

Retrieve an array of folders that meet the criteria that you specify.

Syntax

Retrieve(1)

Function 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, a SimpleOperator, and a 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 folders with an ID between 123456 and 234567, as shown in this code sample.

{
  Property: "ID",
  SimpleOperator: "between",
  Value: ["123456","234567"]
}

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.

Both the LeftOperand and RightOperand objects contain the same content as a simple query. That is, they both contain 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 image folders where the name of the folder contains the phrase "LoyaltyRewards."

{
  LeftOperand: {
    Property: "ContentType",
    SimpleOperator: "equals",
    Value: "image"
  },
  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 folders based on their name, specify Name. This table lists several common properties.

Property Type Description
Name String The name of the folder.
ID Number The unique ID of the folder.
Description String The optional description of the folder.
ContentType String The type of content that the folder contains. For a list of possible values, see Value.
IsEditable Boolean Indicates whether the folder can be edited.
PartnerKey String An identifier for the folder that can be used by external partners.
ObjectID String A unique ID for the folder.
CustomerKey String An external identifier for the folder.

You can also use dot notation to specify fields in child objects. For example, to search based on the name of the parent folder, specify ParentFolder.Name.

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.

If you specify contentType for the Property value, specify the type of folder you want to return. This table lists the possible values for this property.

ContentType Description
abtest A/B Test folder
asset Content asset folder
automated_email Automated email folder
automations Automation Studio folder
buildaudienceactivity Build audience activity folder
campaign Campaign folder
content My contents folder
dataextension Data extensions folder
document My documents folder
email My emails folder
group My groups folder
hidden Hidden items folder
image My images folder
job My tracking folder
list My lists folder
livecontent Live content folder
media Portfolio folder
microsite Microsites folder
micrositelayout Microsite layouts folder
filteractivity Filter activity folder
filterdefinition Data filters definition folder
measure Measures folder
survey My surveys folder
message Message folder
mysubs My subscribers folder
organization Organizations folder
playbooks Playbooks folder
programs2 My programs folder
publication My publication lists folder
queryactivity Query activity folder
template My templates folder
ssjsactivity SSJS Activity folder
suppression_list Suppression Lists folder
triggered_send Triggered sends folder
triggered_send_journeybuilder Journey Builder triggered sends folder
userinitiatedsends User-initiated sends folder
<!--I found these online, but I can't verify them, so I'm leaving them out for now. The previous version of this doc didn't list any possible values at all, so I feel okay leaving these out.--> <!-- | `salesforcedataextension` | Salesforce data extension | | `salesforcesends` | Salesforce sends | | `salesforcesendsv5` | Salesforce sends v5 | | `shared_content` | Shared content | | `shared_contextual_suppression_list` | Shared contextual suppression list | | `shared_data` | Shared data | | `shared_dataextension` | Shared data extensions | | `shared_email` | Shared email messages | | `shared_item` | Shared items | | `shared_portfolio` | Shared portfolios | | `shared_publication` | Shared publication lists | | `shared_salesforcedataextension` | Shared Salesforce data extension | | `shared_suppression_list` | Shared suppression lists | | `shared_survey` | Shared surveys | | `shared_template` | Shared templates | | `synchronizeddataextension` | Synchronized Data Extension | | `condensedlpview` | Condensed preview folder | | `contextual_suppression_list` | Contextual suppression list | | `ELTactivity` | ELT activity | | `email_hidden_messagemodel` | Email hidden message model | | `global_email` | Global email | | `global_email_sub` | Global email subscribers | -->

Usage

To use this function, pass a JSON object that defines your search criteria. The structure of the JSON object differs based on whether you want to perform a simple search or a complex one.

Simple Search Example

In a simple search, the JSON object contains the Property, SimpleOperator, and Value properties. This example returns a list of folders that belong to a parent folder named RewardsProgram.

<script runat="server">
  Platform.Load("core", "1");

  var folders = Folder.Retrieve({
    Property: "ParentFolder.Name",
    SimpleOperator: "equals",
    Value: "RewardsProgram"
  });

  Write(Stringify(folders));
</script>

Complex Search Example

In a complex search, the JSON object contains LeftOperand and RightOperand objects and a LogicalOperator property. The LeftOperand and RightOperand objects each contain a set of Property, SimpleOperator, and Value properties.

This example returns a list of folders in the My Images folder with names that begin with the text "LoyaltyRewards" followed by zero or more other characters.

<script runat="server">
  Platform.Load("core", "1");

  var folders = Folder.Retrieve({
    LeftOperand: {
      Property: "ContentType",
      SimpleOperator: "equals",
      Value: "image"
    },
    LogicalOperator: "AND",
    RightOperand: {
      Property: "Name",
      SimpleOperator: "like",
      Value: "LoyaltyRewards%"
    }
  });

  Write(Stringify(folders));
</script>

Result

Whether you perform a simple or complex search, the structure of the result is the same. The result is a JSON array that contains folder objects. Each folder object also contains an object that describes the properties of the parent folder.

[
  {
    "Name": "LoyaltyRewardsProgramme",
    "ID": 445566,
    "IDSpecified": true,
    "ParentFolder": {
      "Name": "my images",
      "ID": 112233,
      "IDSpecified": true,
      "ParentFolder": null,
      "Description": "",
      "ContentType": "image",
      "IsActive": true,
      "IsActiveSpecified": true,
      "IsEditable": false,
      "IsEditableSpecified": true,
      "AllowChildren": true,
      "AllowChildrenSpecified": true,
      "Client": null,
      "PartnerKey": null,
      "PartnerProperties": null,
      "CreatedDate": "0001-01-01T00:00:00.000",
      "CreatedDateSpecified": false,
      "ModifiedDate": null,
      "ModifiedDateSpecified": false,
      "ObjectID": "af7ca448-b9a2-4a19-83fa-0290cdddd91d",
      "CustomerKey": null,
      "Owner": null,
      "CorrelationID": null,
      "ObjectState": null,
      "IsPlatformObject": false,
      "IsPlatformObjectSpecified": false
    },
    "Description": "",
    "ContentType": "image",
    "IsActive": true,
    "IsActiveSpecified": true,
    "IsEditable": false,
    "IsEditableSpecified": true,
    "AllowChildren": false,
    "AllowChildrenSpecified": true,
    "Client": null,
    "PartnerKey": null,
    "PartnerProperties": null,
    "CreatedDate": "0001-01-01T00:00:00.000",
    "CreatedDateSpecified": false,
    "ModifiedDate": null,
    "ModifiedDateSpecified": false,
    "ObjectID": null,
    "CustomerKey": "",
    "Owner": null,
    "CorrelationID": null,
    "ObjectState": null,
    "IsPlatformObject": false,
    "IsPlatformObjectSpecified": false
  },
  ...
]