ContentAreaObj targets legacy Content Areas (Init, Add, Retrieve, Update, Remove). Use only when you must support older assets; new development should use Content Builder.

Methods

Method Returns Description
ContentAreaObj.Init(key) ContentAreaObjInstance Bind by external key
ContentAreaObj.Add(properties) string Create a content area
ContentAreaObj.Retrieve(filter) object[] Query content areas
<ContentAreaObjInstance>.Update(properties) string Update the initialized content area
<ContentAreaObjInstance>.Remove() string Delete the content area

ContentAreaObj.Init

Initializes a ContentAreaObj instance for the given external key.

Syntax

ContentAreaObj.Init(key)

Parameters

Name Type Required Description
key string Yes External key

Return value

ContentAreaObjInstance

Examples

Platform.Load("core", "1.1.5");
var area = ContentAreaObj.Init("myCA");

ContentAreaObj.Add

Creates a new legacy Content Area with the specified properties. May fail where Content Areas have been fully retired.

Syntax

ContentAreaObj.Add(properties)

Parameters

Name Type Required Description
properties object Yes CustomerKey, Name, CategoryID, Layout, Content, …

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var exampleArea = {
    CustomerKey: "exampleArea",
    Name: "SSJS Content Area Example",
    CategoryID: 123456,
    Layout: "RawText",
    LayoutSpecified: true,
    Content: "<b>This is example content</b>"
};
var status = ContentAreaObj.Add(exampleArea);

ContentAreaObj.Retrieve

Queries content areas matching the given filter. Typically read-only on accounts where creation/update is disabled.

Syntax

ContentAreaObj.Retrieve(filter)

Parameters

Name Type Required Description
filter object Yes WSProxy-style filter

Return value

object[]

Examples

Platform.Load("core", "1.1.5");
var results = ContentAreaObj.Retrieve({
    Property: "CustomerKey",
    SimpleOperator: "equals",
    Value: "myCA"
});

<ContentAreaObjInstance>.Update

Updates the initialized content area with the given properties.

Syntax

<ContentAreaObjInstance>.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 obj = ContentAreaObj.Init("myCA");
var status = obj.Update({ Name: "Name Updated By SSJS" });

<ContentAreaObjInstance>.Remove

Removes the initialized content area.

Syntax

<ContentAreaObjInstance>.Remove()

Return value

"OK" on success.

Examples

Platform.Load("core", "1.1.5");
var obj = ContentAreaObj.Init("myCA");
var status = obj.Remove();