Folder manages Content Builder / Email Studio folders. Call Folder.Init() with no arguments when the folder has no external key, then SetID to bind by numeric folder ID.

Methods

Method Returns Description
Folder.Init([key]) FolderInstance Optional external key
Folder.Add(properties) string Create a child folder
Folder.Retrieve(filter) object[] Query folders (simple or compound filters)
<FolderInstance>.Update(properties) string Update folder attributes
<FolderInstance>.Remove() string Delete the folder
<FolderInstance>.SetID(id) void Bind instance to folder ID when no external key

Folder.Init

Initializes a Folder instance, optionally bound to an external key. Omit the key and call SetID() when the folder has no external key.

Syntax

Folder.Init([key])

Parameters

Name Type Required Description
key string No External key; omit and use SetID() when none exists

Return value

FolderInstance

Examples

Platform.Load("core", "1");
var myFolder = Folder.Init("myFolder");
// When the folder has no external key:
var myIDFolder = Folder.Init();
myIDFolder.SetID(12345);

Folder.Add

Creates a new folder with the specified properties.

Syntax

Folder.Add(properties)

Parameters

Name Type Required Description
properties object Yes Name, CustomerKey, Description, ContentType, ParentFolderID, …

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var newFolder = {
    Name: "Test Add Folder",
    CustomerKey: "test_folder_key",
    Description: "Test added",
    ContentType: "email",
    IsActive: "true",
    IsEditable: "true",
    AllowChildren: "false",
    ParentFolderID: 123456
};
var status = Folder.Add(newFolder);

Folder.Retrieve

Queries folders matching the given filter. Supports compound filters and dot notation (e.g. ParentFolder.Name).

Syntax

Folder.Retrieve(filter)

Parameters

Name Type Required Description
filter object Yes WSProxy-style filter

Return value

object[]

Examples

Platform.Load("core", "1");
var folders = Folder.Retrieve({
    Property: "ParentFolder.Name",
    SimpleOperator: "equals",
    Value: "RewardsProgram"
});
Write(Stringify(folders));

<FolderInstance>.Update

Updates the initialized folder with the given properties.

Syntax

<FolderInstance>.Update(properties)

Parameters

Name Type Required Description
properties object Yes Attributes to change

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var myFolder = Folder.Init("myFolder");
var status = myFolder.Update({ Name: "Updated Folder Name" });

<FolderInstance>.Remove

Removes the initialized folder.

Syntax

<FolderInstance>.Remove()

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var myFolder = Folder.Init("myFolder");
myFolder.Remove();

<FolderInstance>.SetID

Binds the instance to a folder by numeric ID. Use after Folder.Init() with no key when targeting a folder that only has a numeric ID.

Syntax

<FolderInstance>.SetID(id)

Parameters

Name Type Required Description
id number Yes Folder ID

Return value

None (void).

Examples

Platform.Load("core", "1.1.5");
var myIDFolder = Folder.Init();
myIDFolder.SetID(12345);