AttributeValue
Reads an attribute of the current message or page context by name. Runtime-proven on a live Marketing Cloud Engagement CloudPage — system attributes resolve there, the name is matched without regard to case, and an unknown name gives an empty value instead of failing.
Syntax
AttributeValue(attributeName) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
attributeName |
string | Yes | Attribute name, matched without regard to case; an empty name aborts the page |
Example
%%[
VAR @context
SET @context = AttributeValue("_messagecontext")
]%%
Rendered in: %%=v(@context)=%%
On a CloudPage this renders LANDINGPAGE.
An unknown name is safe to call — it renders nothing rather than failing:
%%[
VAR @maybe
SET @maybe = AttributeValue("no_such_attribute")
IF Empty(@maybe) THEN
SET @maybe = "not available"
ENDIF
]%%
Return value
string — the attribute value, or an empty value when the name resolves to nothing.
The value domain is open, so there is no set of tokens to test against. The empty result is a real empty string, not a swallowed failure: Empty() on the same call answers true, and nesting the call inside a Concat renders the two surrounding characters with nothing between them.
Behaviour
System attributes resolve on a CloudPage. Even with no subscriber involved, _messagecontext rendered LANDINGPAGE, memberid rendered the business unit MID and jobid rendered 0, all at HTTP 200.
Subscriber attributes do not. emailaddr and _subscriberkey rendered empty on a CloudPage. That is a statement about the context, not a defect — in a send those names carry values.
The name is matched without regard to case. _messagecontext and _MessageContext rendered the identical value.
An unknown name is an empty value, not a failure. An invented name rendered nothing between its delimiters and the page still returned HTTP 200.
A numeric argument is accepted and answers empty without failing. This is not a widening of the parameter type — a number is not an alternative form of an attribute name, it simply never matches one.
An empty name is not survivable. AttributeValue("") aborts its block with HTTP 422 while sibling blocks on the same page render normally. Guard the name before calling if it comes from a variable.
Exactly one argument. Zero-argument and two-argument calls each abort their own block while the rest of the page keeps rendering.
Show test script
%%[
VAR @b
SET @b = RequestParameter("b")
/* known-good control: renders on every request, so a run of HTTP 422s
can be told apart from a broken deploy */
OutputLine(Concat("CTRL=[", Uppercase("ok"), "]"))
OutputLine(Concat("--- AV start ---"))
/* a name that exists nowhere: empty, not an abort — and confirmed with a
second function rather than read off a blank pair of brackets */
OutputLine(Concat("AV_MISSING=[", AttributeValue("NoSuchAttributeZq7"), "]"))
OutputLine(Concat("AV_MISSING_CHK=[", IIf(Empty(AttributeValue("NoSuchAttributeZq7")), "empty", "not-empty"), "]"))
OutputLine(Concat("AV_IN_CONCAT=[", Concat("<", AttributeValue("NoSuchAttributeZq7"), ">"), "]"))
/* system attributes DO resolve on a page with no subscriber */
OutputLine(Concat("AV_MSGCTX=[", AttributeValue("_messagecontext"), "]"))
OutputLine(Concat("AV_MID=[", AttributeValue("memberid"), "]"))
OutputLine(Concat("AV_JOBID=[", AttributeValue("jobid"), "]"))
/* the same name in a different case resolves to the same value */
OutputLine(Concat("AV_MIXEDCASE=[", AttributeValue("_MessageContext"), "]"))
/* subscriber-scoped names are empty here because the page has no send
context — a context statement, not a defect */
OutputLine(Concat("AV_EMAIL=[", AttributeValue("emailaddr"), "]"))
OutputLine(Concat("AV_SUBKEY=[", AttributeValue("_subscriberkey"), "]"))
OutputLine(Concat("--- AV done ---"))
/* an empty name: aborts this branch only */
IF @b == "av_empty" THEN
OutputLine(Concat("--- av_empty start ---"))
OutputLine(Concat("AV_EMPTYNAME=[", AttributeValue(""), "]"))
OutputLine(Concat("--- av_empty done ---"))
ENDIF
/* a non-string argument */
IF @b == "av_num" THEN
OutputLine(Concat("--- av_num start ---"))
OutputLine(Concat("AV_NUM=[", AttributeValue(123), "]"))
OutputLine(Concat("--- av_num done ---"))
ENDIF
/* argument counts the signature does not allow: each aborts its branch */
IF @b == "av_arity" THEN
OutputLine(Concat("--- av_arity start ---"))
OutputLine(Concat("AV0=[", AttributeValue(), "]"))
OutputLine(Concat("AV2=[", AttributeValue("_messagecontext", "x"), "]"))
OutputLine(Concat("--- av_arity done ---"))
ENDIF
]%%
Every marker and label in the test script goes through Concat(...), including single-argument ones. A bare string literal passed to OutputLine renders an empty line while the page still returns HTTP 200, so the marker silently vanishes.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |