sfmc // AMPscriptPRODUCTION

Defensive LookupRows()

Handle zero-row lookups explicitly before reading row fields.

ampscriptlookuprowsrowcountdefensive
Context Pack →Open Workspace →
Trust & provenancePRODUCTION
Evidence tierPRODUCTIONOfficial sources0Other sources0Last verifiedNot recorded

Evidence tier describes my hands-on relationship with the content. Official sources describe platform contracts/documentation. Production observations should not automatically be treated as official limits.

%%[
VAR @rows, @row, @count, @name
SET @rows = LookupRows('Customer_Data','SubscriberKey',_subscriberkey)
SET @count = RowCount(@rows)

IF @count > 0 THEN
  SET @row = Row(@rows,1)
  SET @name = Field(@row,'FirstName')
ELSE
  SET @name = 'Cliente'
ENDIF
]%%
Olá %%=v(@name)=%%
Operational notes

Treat lookup misses as a normal branch unless the missing record is truly exceptional.