AttributeValue
This function returns the value of an attribute based on the context of the Contact or Subscriber. These values are derived from a field or attribute related to the Contact or Subscriber that the message is sent to. These can include the following data sources:
- Email Subscriber Profile Attributes
- Sendable Data Extension Fields
- Journey Builder Entry Source Attributes
- MobileConnect List Attributes
- MobilePush Attributes
The function is similar to Attribute Personalization Strings which return a contextual value of an attribute. However, this function will return null
if the attribute is not available in the data source context. This can be useful when working with data sources that use different schemas.
Argument
AttributeValue(1)
Ordinal | Type | Required | Description |
---|---|---|---|
1 | String | True | The attribute name |
Example 1
The following example indicates the behavior when an email is sent from a Sendable Data Extension which does not include a ‘first name’ field.
%%[
var @firstName, @displayName
set @firstName = [First Name]
if empty(@firstName) then
set @displayName = "friend"
else
set @displayName = @firstName
endif
]%%
<p>Hello %%=v(@displayName)=%%,</p>
Output
As the field is not available, an error will be generated and the email will not be sent.
Unable to generate preview
An unrecognized expression appears in a script block.
Script Expression: [First Name]
MemberID: 87654321
JobID: 0
Example 2
Not a subscriber? Subscribe now.
Example 3
Not a subscriber? Subscribe now.