Platform.Function.ContentArea
→ stringRetrieves rendered content from a classic Content Area by ID. Salesforce documents Content Areas as deprecated in favour of Content Builder blocks.
Syntax
Platform.Function.ContentArea(id[, regionName, stopOnError, fallbackContent])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
string | number | Yes | ID of the Content Area. A numeric string for the same id works too. |
regionName |
string | No | Impression region for content tracking. ⚠️ Supplying it makes the call throw a resolved-value error — see below. |
stopOnError |
boolean | No | When true, throws on retrieval failure; when false, the call continues. ⚠️ Unreachable — the call already throws on regionName. |
fallbackContent |
string | No | Content to display when the area cannot be retrieved. ⚠️ Unreachable — never emitted at runtime. |
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");
/*
* Chapter: Parameters —
* Platform.Function.ContentArea(id[, regionName, stopOnError, fallbackContent])
*
* Proves:
* 1. The member resolves on Platform.Function (typeof "clrmethodinfo",
* the engine's uniform marker for a host CLR method — it proves
* nothing about existence, only invocation does).
* 2. The required `id` parameter alone — the minimal documented call —
* returns the content area's markup, for an ID that exists.
* 3. Number↔string type-acceptance for `id`: the documented number form
* AND its numeric-string counterpart both return the same content, so
* the Parameters table widens the type to `string | number`.
* 4. An ID that does not resolve throws; that throw is about the ID, not
* about the call shape, because arity 1 succeeds in the same request.
* 5. DEV the documented optional `regionName` (parameter 2) does not
* work: it is rejected as a resolved-value parameter. A string
* literal, the empty string and null all throw.
* 6. Because parameter 2 is rejected, the documented `stopOnError`
* (parameter 3) and `fallbackContent` (parameter 4) are UNREACHABLE:
* arity 3 and arity 4 throw, so neither stopOnError:false nor the
* fallback string ever takes effect.
* 7. Arities outside the documented 1..4 range (0 and 5) throw the
* "security descriptor" error. Because arity 1 succeeds in this same
* request, existence is independently established and that message
* settles ARITY only.
*
* EXPECTED OUTPUT: every line starts with PASS. A FAIL means the runtime no
* longer matches the documented claim and the page must be revised.
*/
function assert(id, actual, expected) {
Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function assertThrows(id, fn) {
var threw = false, msg = "";
try { fn(); } catch (ex) { threw = true; msg = "" + ex.message; }
Platform.Response.Write((threw ? "PASS " : "FAIL ") + id + " -> " + (threw ? "threw: " + msg : "did NOT throw") + "\n");
}
/* 1. The member resolves as a host CLR method. */
assert("typeof Platform.Function.ContentArea is clrmethodinfo", "" + (typeof Platform.Function.ContentArea), "clrmethodinfo");
/* Fixture: create a Content Area and keep the ID the platform assigned. */
var prox = new Script.Util.WSProxy();
var caName = "ssjsg-ca-" + Platform.Function.GUID().substring(0, 8);
var caBody = "BODY-" + caName;
var created = prox.createItem("ContentArea", { Name: caName, CustomerKey: caName, Content: caBody, IsDynamicContent: false });
var caId = created.Results[0].NewObjectID;
assert("the fixture Content Area was created", "" + created.Status, "OK");
/* 2. The minimal documented call (id only) returns the content. */
assert("arity 1 with the fixture id returns the content", "" + Platform.Function.ContentArea(caId), caBody);
/* 3. Number↔string type-acceptance for id — both return the same content. */
assert("type-accept: the numeric-string id returns the same content", "" + Platform.Function.ContentArea("" + caId), caBody);
/* 4. An id that does not resolve throws — that is about the id, not the shape. */
assertThrows("an unresolvable id throws", function () {
return Platform.Function.ContentArea(123456);
});
/* 5. DEV the documented optional regionName is rejected as a resolved value. */
assertThrows("DEV arity 2 regionName string literal throws (docs: optional impression region)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion");
});
assertThrows("DEV arity 2 empty-string regionName throws as well", function () {
return Platform.Function.ContentArea(caId, "");
});
assertThrows("DEV arity 2 null regionName throws as well", function () {
return Platform.Function.ContentArea(caId, null);
});
/* 6. stopOnError and fallbackContent are unreachable behind that rejection. */
assertThrows("DEV arity 3 stopOnError=false still throws (docs: false lets the call proceed)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", false);
});
assertThrows("DEV arity 3 stopOnError=true throws", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", true);
});
assertThrows("DEV arity 4 fallbackContent never emitted, call throws (docs: fallback is displayed)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", false, "Fallback text here");
});
/* 7. Off-signature arities throw the security-descriptor error (arity, not existence). */
assertThrows("arity 0 throws", function () {
return Platform.Function.ContentArea();
});
assertThrows("arity 5 throws", function () {
return Platform.Function.ContentArea(caId, "reg", false, "fb", "extra");
});
/* Cleanup. */
prox.deleteItem("ContentArea", { ID: caId });
</script>
Description
Platform.Function.ContentArea() retrieves and renders content from a classic (legacy) SFMC Content Area identified by its ID.
Salesforce’s documentation marks Content Areas as deprecated in favour of Content Builder. For new work, migrate content to Content Builder blocks and use Platform.Function.ContentBlockByID().
Runtime note: only the single-argument form works. Given the id of a Content Area that actually exists, the 1-argument call returns that area’s content, and the same id passed as a numeric string works as well. An id that does not resolve throws an evaluation error — that throw says the id did not resolve, nothing more. Adding the documented regionName throws a different, resolved-value error, which makes stopOnError and fallbackContent unreachable. The bare-name ContentArea() Core form behaves the same.
The official docs present all four parameters as usable. At runtime only the first one is: supplying regionName fails with a resolved-value error before stopOnError or fallbackContent can take effect, so the documented 4-argument form never works.
Show test script — only the 1-argument form works
<script runat="server">
Platform.Load("core", "1.1.5");
/*
* Differs-from-docs claim: the official Salesforce documentation presents
* Platform.Function.ContentArea(id, regionName, stopOnError, fallbackContent)
* as a four-parameter callable, with stopOnError:false letting a failed call
* proceed and fallbackContent shown when nothing is returned. At runtime
* ONLY the single-argument form works.
*
* Official docs: ContentArea(123456,"impressionRegion",false,"defaultContentHere")
* returns the content the area produced.
* SFMC runtime: arity 1 -> returns the content area's markup
* arity 2/3/4 -> "A ContentArea function call includes an
* invalid parameter value. … must be a
* literal (constant) values."
* Parameter Name: ImpressionRegionName
* Parameter Ordinal: 2
* Parameter Type: ResolvedValueParameter
* arity 0/5+ -> "Unable to retrieve security descriptor for
* this frame."
* (each message is printed verbatim by its assertion below)
*
* Proves every part of the claim:
* 1. Arity 1 returns the content for the fixture created in this request.
* 2. DEV arity 2 throws the resolved-value error for every regionName
* shape: string literal, concatenation, variable, empty string and
* null. So the failure is not "literal vs variable" — the parameter
* cannot be supplied at all.
* 3. DEV arity 3 and arity 4 throw the same parameter-2 error, which is
* what makes stopOnError and fallbackContent unreachable: the fallback
* string is never emitted.
* 4. Arity 0 and arity 5 throw the security-descriptor error. Existence is
* independently established by the successful arity-1 call in this same
* request, so that message settles ARITY only.
* 5. The bare-name Core alias behaves identically, so the deviation is not
* specific to the Platform.Function namespace.
*
* EXPECTED OUTPUT: every line starts with PASS.
*/
function assert(id, actual, expected) {
Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function assertThrows(id, fn) {
var threw = false, msg = "";
try { fn(); } catch (ex) { threw = true; msg = "" + ex.message; }
Platform.Response.Write((threw ? "PASS " : "FAIL ") + id + " -> " + (threw ? "threw: " + msg : "did NOT throw") + "\n");
}
/* Fixture: create a Content Area and keep the ID the platform assigned. */
var prox = new Script.Util.WSProxy();
var caName = "ssjsg-ca-" + Platform.Function.GUID().substring(0, 8);
var caBody = "BODY-" + caName;
var created = prox.createItem("ContentArea", { Name: caName, CustomerKey: caName, Content: caBody, IsDynamicContent: false });
var caId = created.Results[0].NewObjectID;
assert("the fixture Content Area was created", "" + created.Status, "OK");
/* 1. Arity 1 works. */
assert("arity 1 returns the content", "" + Platform.Function.ContentArea(caId), caBody);
/* 2. DEV every regionName shape is rejected as a resolved value. */
assertThrows("DEV arity 2 string literal regionName throws", function () {
return Platform.Function.ContentArea(caId, "impressionRegion");
});
assertThrows("DEV arity 2 concatenated regionName throws", function () {
return Platform.Function.ContentArea(caId, "impression" + "Region");
});
var dynRegion = "impressionRegion";
assertThrows("DEV arity 2 variable regionName throws", function () {
return Platform.Function.ContentArea(caId, dynRegion);
});
assertThrows("DEV arity 2 empty-string regionName throws", function () {
return Platform.Function.ContentArea(caId, "");
});
assertThrows("DEV arity 2 null regionName throws", function () {
return Platform.Function.ContentArea(caId, null);
});
/* 3. DEV stopOnError and fallbackContent never take effect. */
assertThrows("DEV arity 3 stopOnError=false throws (docs: the call proceeds)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", false);
});
assertThrows("DEV arity 3 stopOnError=true throws", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", true);
});
assertThrows("DEV arity 4 throws so fallbackContent is never emitted (docs: fallback shown)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", false, "FALLBACK");
});
assertThrows("DEV arity 4 with a null regionName throws as well", function () {
return Platform.Function.ContentArea(caId, null, false, "FALLBACK");
});
/* 4. Off-signature arities throw the security-descriptor error (arity, not existence). */
assertThrows("arity 0 throws", function () {
return Platform.Function.ContentArea();
});
assertThrows("arity 5 throws", function () {
return Platform.Function.ContentArea(caId, "reg", false, "fb", "extra");
});
/* 5. The bare-name Core alias behaves identically. */
assert("bare-name arity 1 returns the same content", "" + ContentArea(caId), caBody);
assertThrows("DEV bare-name arity 2 throws as well", function () {
return ContentArea(caId, "impressionRegion");
});
/* Cleanup. */
prox.deleteItem("ContentArea", { ID: caId });
</script>
Difference from the global ContentArea() form
The bare-name global ContentArea() function accepts the same first two parameters but differs in the 3rd and 4th:
Platform.Function.ContentArea() |
ContentArea() (global) |
|
|---|---|---|
| 3rd parameter | stopOnError: boolean |
errorMsg: string |
Requires Platform.Load |
No | Yes — Platform.Load("core", "1.1.5") |
See ContentArea for the bare-name Core variant.
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");
/*
* Chapter: Description — what the single-argument form does, why a throw
* means the ID did not resolve, and how the bare-name Core form compares.
*
* Proves:
* 1. A Content Area created in this request is returned by
* Platform.Function.ContentArea(id), for the numeric ID and for its
* numeric-string counterpart.
* 2. A throw at arity 1 means the ID did not resolve, nothing more: an
* unknown id, 0 and a negative id throw while the fixture id keeps
* succeeding in the same request.
* 3. The bare-name Core form IS defined as a real function after
* Platform.Load("core", "1.1.5") — typeof is "function", not the
* "clrmethodinfo" marker the Platform.Function form reports — and it
* behaves identically: arity 1 returns the content, arity 2 and 3
* throw.
* 4. The recommended replacement path is real: Platform.Function
* resolves ContentBlockByID as a host method (the documented modern
* substitute for classic Content Areas).
*
* NOT ASSERTED: any runtime effect of the Salesforce deprecation notice.
* Deprecation is a documentation fact; nothing observable in this request
* distinguishes a deprecated member from a supported one.
*
* EXPECTED OUTPUT: every line starts with PASS.
*/
function assert(id, actual, expected) {
Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function assertThrows(id, fn) {
var threw = false, msg = "";
try { fn(); } catch (ex) { threw = true; msg = "" + ex.message; }
Platform.Response.Write((threw ? "PASS " : "FAIL ") + id + " -> " + (threw ? "threw: " + msg : "did NOT throw") + "\n");
}
/* Fixture: create a Content Area and keep the ID the platform assigned. */
var prox = new Script.Util.WSProxy();
var caName = "ssjsg-ca-" + Platform.Function.GUID().substring(0, 8);
var caBody = "BODY-" + caName;
var created = prox.createItem("ContentArea", { Name: caName, CustomerKey: caName, Content: caBody, IsDynamicContent: false });
var caId = created.Results[0].NewObjectID;
assert("the fixture Content Area was created", "" + created.Status, "OK");
/* 1. The fixture id resolves, as a number and as a numeric string. */
assert("the fixture id returns the content", "" + Platform.Function.ContentArea(caId), caBody);
assert("the numeric-string id returns the same content", "" + Platform.Function.ContentArea("" + caId), caBody);
/* 2. Ids that do not resolve throw. */
assertThrows("an unknown id throws", function () {
return Platform.Function.ContentArea(123456);
});
assertThrows("id 0 throws", function () {
return Platform.Function.ContentArea(0);
});
assertThrows("a negative id throws", function () {
return Platform.Function.ContentArea(-1);
});
/* 3. The bare-name Core form behaves identically. */
assert("typeof the bare-name ContentArea is function after Platform.Load", "" + (typeof ContentArea), "function");
assert("bare-name arity 1 returns the same content", "" + ContentArea(caId), caBody);
assertThrows("bare-name arity 2 with a regionName throws too", function () {
return ContentArea(caId, "impressionRegion");
});
assertThrows("bare-name arity 3 with the string errorMsg throws too", function () {
return ContentArea(caId, "impressionRegion", "Could not load content area");
});
/* 4. The documented modern replacement resolves as a host method. */
assert("typeof Platform.Function.ContentBlockByID is clrmethodinfo", "" + (typeof Platform.Function.ContentBlockByID), "clrmethodinfo");
/* Cleanup. */
prox.deleteItem("ContentArea", { ID: caId });
</script>
Examples
The single-argument form works when the id resolves to an existing Content Area:
// returns the content area's rendered markup
var content = Platform.Function.ContentArea(935116);
Platform.Response.Write(content);
The documented 4-argument form does not — it is shown as the documented shape, not as working code:
// throws: A ContentArea function call includes an invalid parameter value.
// … Parameter Name: ImpressionRegionName
var content = Platform.Function.ContentArea(935116, "impressionRegion", false, "Fallback text here");
Platform.Response.Write(content);
For new content, use Platform.Function.ContentBlockByID() instead.
Show test script
<script runat="server">
Platform.Load("core", "1.1.5");
/*
* Chapter: Examples — the working single-argument form, the documented
* 4-argument form, and the replacement.
*
* Proves:
* 1. Example 1, the plain 1-argument call, returns the content area's
* markup exactly as the docs show — provided the ID resolves.
* 2. DEV example 2, the full 4-argument call with stopOnError and a
* fallback, throws — the documented fallbackContent is never written
* to the response.
* 3. Because that call throws, Platform.Response.Write() never receives a
* value: the variable it assigns to stays undefined.
* 4. The page's recommended replacement,
* Platform.Function.ContentBlockByID, resolves as a host CLR method.
*
* NOT ASSERTED: whether an impression is recorded for the region. Parameter
* 2 cannot be supplied at all, and impression counts only surface in
* Marketing Cloud tracking reports after a send is processed, which is not
* observable from within this request.
*
* EXPECTED OUTPUT: every line starts with PASS.
*/
function assert(id, actual, expected) {
Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function assertThrows(id, fn) {
var threw = false, msg = "";
try { fn(); } catch (ex) { threw = true; msg = "" + ex.message; }
Platform.Response.Write((threw ? "PASS " : "FAIL ") + id + " -> " + (threw ? "threw: " + msg : "did NOT throw") + "\n");
}
function typeOf(fn) {
try { return "" + fn(); } catch (ex) { return "THREW: " + ("" + ex.message); }
}
/* Fixture: create a Content Area and keep the ID the platform assigned. */
var prox = new Script.Util.WSProxy();
var caName = "ssjsg-ca-" + Platform.Function.GUID().substring(0, 8);
var caBody = "BODY-" + caName;
var created = prox.createItem("ContentArea", { Name: caName, CustomerKey: caName, Content: caBody, IsDynamicContent: false });
var caId = created.Results[0].NewObjectID;
assert("the fixture Content Area was created", "" + created.Status, "OK");
/* 1. Example 1 — the plain 1-argument call. */
assert("example 1: ContentArea(id) returns the content", "" + Platform.Function.ContentArea(caId), caBody);
/* 2. DEV example 2 — the full 4-argument call with a fallback. */
assertThrows("DEV example 2: the 4-argument call throws (docs: shows the fallback)", function () {
return Platform.Function.ContentArea(caId, "impressionRegion", false, "Fallback text here");
});
/* 3. Neither the fallback nor any value is assigned. */
var content2;
try { content2 = Platform.Function.ContentArea(caId, "impressionRegion", false, "Fallback text here"); } catch (ex2) { /* documented throw */ }
assert("example 2: the fallback is never assigned", typeOf(function () { return typeof content2; }), "undefined");
assert("example 2: the fallback string is NOT the result", content2 === "Fallback text here" ? "true" : "false", "false");
/* 4. The recommended replacement resolves as a host method. */
assert("typeof Platform.Function.ContentBlockByID is clrmethodinfo", "" + (typeof Platform.Function.ContentBlockByID), "clrmethodinfo");
/* Cleanup. */
prox.deleteItem("ContentArea", { ID: caId });
</script>