Row
Returns a single row from a rowset by its 1-based index. Runtime-proven on a live Marketing Cloud Engagement CloudPage — including that index 0 aborts the page.
Syntax
Row(rowset, rowIndex) → row
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
rowset |
rowset | Yes | A rowset from LookupRows, LookupOrderedRows, or a BuildRowsetFrom* function |
rowIndex |
number | Yes | 1-based index of the row to return |
Example
%%[
VAR @rows, @row
SET @rows = LookupRows("AMP_VERIFY_SCRATCH", "FirstName", "Alice")
SET @row = Row(@rows, 1)
]%%
First Id: %%=v(Field(@row, "Id"))=%%
With Alice rows A1 and A3, renders First Id: A1.
Combine with RowCount to walk every row:
%%[
VAR @rows, @i
SET @rows = LookupRows("AMP_VERIFY_SCRATCH", "FirstName", "Alice")
FOR @i = 1 TO RowCount(@rows) DO
]%%
%%=v(Field(Row(@rows, @i), "Id"))=%%
%%[ NEXT @i ]%%
Return value
row — the row object at the given 1-based index, whose columns are read with Field.
There is no empty-row sentinel: an out-of-range index aborts rather than returning a testable value (see Behaviour).
Behaviour
Rowsets are read 1-based. Row(rowset, 1) returns the first row; the first Alice row read back Id as A1.
Index 0 or out-of-range aborts the page. Row(rowset, 0) aborts the CloudPage with HTTP 422 — everything already rendered is discarded and there is no error value to test. Always guard the read with RowCount(rowset) > 0 and only pass indices in 1..RowCount.
Show test script
%%[
VAR @b, @rs
SET @b = RequestParameter("b")
IF @b == "zzz" THEN
OutputLine(Concat("CTRL=[alive]"))
ENDIF
IF @b == "safe" THEN
DeleteData("AMP_VERIFY_SCRATCH", "Id", "A1")
DeleteData("AMP_VERIFY_SCRATCH", "Id", "A3")
InsertData("AMP_VERIFY_SCRATCH", "Id", "A1", "FirstName", "Alice", "Score", 10)
InsertData("AMP_VERIFY_SCRATCH", "Id", "A3", "FirstName", "Alice", "Score", 30)
SET @rs = LookupRows("AMP_VERIFY_SCRATCH", "FirstName", "Alice")
OutputLine(Concat("Row 1 Id=[", Field(Row(@rs, 1), "Id"), "] Score=[", Field(Row(@rs, 1), "Score"), "]"))
ENDIF
/* fetch ?b=index0 - HTTP 422, nothing renders: Row(rowset, 0) aborts */
IF @b == "index0" THEN
OutputLine(Concat("--- index0 start ---"))
SET @rs = LookupRows("AMP_VERIFY_SCRATCH", "FirstName", "Alice")
OutputLine(Concat("Row 0 Id=[", Field(Row(@rs, 0), "Id"), "]"))
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
Field— reads a named column from the returned rowRowCount— the guard that keepsrowIndexin rangeLookupRows— produces the rowset- Official reference · ampscript.guide