Field
Reads a named column from a rowset row. Runtime-proven on a live Marketing Cloud Engagement CloudPage — including that a missing column aborts the page unless the third argument is passed.
Syntax
Field(row, fieldName[, exceptionIfNotFound]) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
row |
row | Yes | A row returned by Row(rowset, index) |
fieldName |
string | Yes | Name of the column to read |
exceptionIfNotFound |
boolean | number | No | Pass 0 (or false) to get an empty string for a missing column instead of aborting; omit or 1/true to abort |
Example
%%[
VAR @rows, @row
SET @rows = LookupRows("AMP_VERIFY_SCRATCH", "Id", "A1")
SET @row = Row(@rows, 1)
]%%
Name: %%=v(Field(@row, "FirstName"))=%%
With row A1 whose FirstName is Alice, renders Name: Alice.
For a column that may not exist, pass the third argument 0 so a missing column yields an empty string instead of aborting the page:
%%[
VAR @surcharge
SET @surcharge = Field(@row, "PerBagSurcharge", 0)
]%%
Return value
string — the value of the named column in the given row.
The third argument controls the missing-column path, not a default for an existing-but-empty column: an empty cell returns an empty string in every form.
Behaviour
Reads a named column from a row. Field(Row(rowset, 1), "FirstName") returned Alice. Column names are case-insensitive.
A missing column aborts in the two-argument form. Field(row, "NoSuchColumn") aborts the CloudPage with HTTP 422 — everything already rendered is discarded.
The third argument suppresses that abort. Field(row, "NoSuchColumn", 0) returns an empty string instead of aborting. The argument is exception-if-not-found, not a default value: it only governs whether a missing column raises, so prefer the three-argument form for any column that may be absent.
Show test script
%%[
VAR @b, @rs, @row
SET @b = RequestParameter("b")
IF @b == "zzz" THEN
OutputLine(Concat("CTRL=[alive]"))
ENDIF
IF @b == "safe" THEN
DeleteData("AMP_VERIFY_SCRATCH", "Id", "A1")
InsertData("AMP_VERIFY_SCRATCH", "Id", "A1", "FirstName", "Alice", "Score", 10)
SET @rs = LookupRows("AMP_VERIFY_SCRATCH", "Id", "A1")
SET @row = Row(@rs, 1)
/* present column, two-arg form */
OutputLine(Concat("Field(FirstName)=[", Field(@row, "FirstName"), "]"))
/* missing column, three-arg 0 = do-not-abort, returns empty string */
OutputLine(Concat("Field(missing,0)=[", Field(@row, "NoSuchColumn", 0), "]"))
ENDIF
/* fetch ?b=missing2arg - HTTP 422: two-arg Field on a missing column aborts */
IF @b == "missing2arg" THEN
OutputLine(Concat("--- missing2arg start ---"))
SET @rs = LookupRows("AMP_VERIFY_SCRATCH", "Id", "A1")
OutputLine(Concat("Field(missing)=[", Field(Row(@rs, 1), "NoSuchColumn"), "]"))
ENDIF
]%%
OutputLine given a bare string literal renders an empty line. Wrap the argument in Concat() or your start and done markers vanish silently — which looks exactly like the function failing.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | Yes, from API 67.0 |
See also
Row— returns the row this reads fromLookupRows— produces the rowsetLookup— a single scalar without a rowset- Official reference · ampscript.guide