This function returns the value of a field from a row set or the value of an application programming interface (API) object property.



Ordinal Type Required Description
1 String True Row set or API object from which to return the value or property
2 String True Name of the row set field or API object property to retrieve
3 Boolean False Indicates whether to return an empty string value or an error if the specified field or property does not exist. Specifying 0 will return a null value, while 1 will result in a runtime error. The default value is 1.

Example 1

Data Extension: LoyaltyMembers

Name Data Type Length Primary Key Nullable Default Value
EmailAddress EmailAddress 254 N N
SubscriberKey Text 254 Y N
FirstName Text 50 N Y
LastName Text 50 N Y
Created Date N Y Current Date

The LoyaltyMembers Data Extension includes these rows:

EmailAddress SubscriberKey FirstName LastName Created
[email protected] 8473 Doug Smith 2017-10-21 12:01
[email protected] 5497 Suzy Jackson 2017-10-20 11:01
[email protected] 7114 Dale Cameron 2017-10-19 10:01

If the target field does not exist and 0 is specified as the third parameter, an empty string is returned. Otherwise a runtime error occurs.


var @rows, @row, @rowCount
var @emailAddress
set @emailAddress = "[email protected]"

set @rows = LookupRows("LoyaltyMembers","emailAddress", @emailAddress)
set @rowCount = rowcount(@rows)

if @rowCount > 0 then

  var @firstName, @favoriteColor
  set @row = row(@rows,1) /* get row #1 */
  set @firstName = field(@row,"FirstName")
  set @favoriteColor = field(@row,"FavoriteColor",0)


FirstName: %%=v(@firstName)=%%
<br>FavoriteColor: %%=v(@favoriteColor)=%%

%%[ else ]%%

No rows found

%%[ endif ]%%


FirstName: Doug

Example 2

Not a subscriber? Subscribe now.