What would be the correct script for the following?
%%FieldName%%
, fallback = no information available
This is how I would approach it:
%%[
var @fieldName
set @fieldName = AttributeValue("fieldName")
if not empty(@fieldName) then
]%%
%%=v(@fieldName)=%%
%%[ else ]%%
no information available
%%[ endif ]%%
or in a single block:
%%[
var @fieldName
set @fieldName = AttributeValue("fieldName")
if not empty(@fieldName) then
output(concat(@fieldName))
else
output("no information available")
endif
]%%
or shorter:
%%=iif(empty(AttributeValue("fieldName"), "no information available", AttributeValue("fieldName")))=%%
Using raw personalization strings is risky, IMO. If fieldname
didn't exist in your send context for some reason, the email would blow up. Using AttributeValue() will return an empty string in that case.
%%[ var @this set @this = FieldName]%%
%%[IF @this == "" or @this is NULL THEN]%%
some text here to signify that it's blank
%%[ELSE]%% %%FieldName%%,
%%[ENDIF]%%
Taken from: https://help.salesforce.com/articleView?id=000213691&type=1