Verification in progress Test scripts included

Syntax

Row(rowset, rowIndex)  →  row
2 arguments — exactly

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

%%[
  SET @rows = RetrieveSalesforceObjects("Contact", "Id", "IsDeleted", "=", "false")
  IF RowCount(@rows) > 0 THEN
    SET @first = Row(@rows, 1)
    SET @idLength = Length(Field(@first, "Id"))
  ENDIF
]%%
%%=v(@idLength)=%%

Renders 18: the first row of the Contact query carries an 18-character Id.

Return value

row — the row at the given 1-based index, read with Field.

Behaviour

Row 1 of a RetrieveSalesforceObjects rowset is readable. Row(@rows, 1) on a live Contact query gave a row whose Id column had 18 characters.

Rows of a BuildRowSetFromString rowset read back as true. With BuildRowSetFromString("North**South**East**West", "**"), Field(Row(@rs, 1), 1) and Field(Row(@rs, 4), 1) both rendered true, in the variable form and in the nested inline form. The value comes back the same way from Field on such rows in general, so it is not clear whether Row or Field is the cause.

Index 0 fails. An email with Row(@rs, 0) saved and published, but rendering it failed with HTTP 500. Only pass indices from 1 up to RowCount(rowset).

An index past the last row was not tested in Next.

Show Next test script
<!-- Marketing Cloud Next test script for Row. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[true] got=[%%=Field(Row(BuildRowSetFromString("North**South**East**West","**"),4),1)=%%]</p>
<p>c2 expect=[true] got=[%%[ SET @w1rs = BuildRowSetFromString("North**South**East**West","**") SET @w1r = Row(@w1rs,1) SET @w1v = Field(@w1r,1) ]%%%%=v(@w1v)=%%]</p>
<p>c3 expect=[true] got=[%%[ SET @w2rs = BuildRowSetFromString("North**South**East**West","**") SET @w2r = Row(@w2rs,4) SET @w2v = Field(@w2r,1) ]%%%%=v(@w2v)=%%]</p>
<p>c4 expect=[true] got=[%%[ SET @w3rs = BuildRowSetFromString("North**South**East**West","**") ]%%%%=Field(Row(@w3rs, 1), 1)=%%]</p>

Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
     would stop the whole preview or block the save. -->

<!-- email 1: expect that the email saves, but the preview fails (HTTP 500) -->
%%[ SET @we1rs = BuildRowSetFromString("a,b,c",",") SET @we1r = Row(@we1rs,0) ]%%%%=v(Field(@we1r,1))=%%

Availability & differences

PlatformAvailable
Marketing Cloud EngagementYes
Marketing Cloud NextYes, from API 67.0

See also