Skip to content

Instantly share code, notes, and snippets.

@wvpv
Created December 11, 2015 17:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save wvpv/ff17dc9cf0b44296ef26 to your computer and use it in GitHub Desktop.
%%[ /* IIF() */
var @firstName, @intro
set @firstName = AttributeValue("firstName") /* returns blank if null */
set @intro = "Hello"
if not empty(@firstName) then
set @intro = concat(@intro, ", ", @firstName)
endif
set @intro = concat(@intro,"! Check out these deals")
]%%
inline: %%=concat("Hello",iif(empty(@firstName), "",concat(", ", @firstName)),"! Check out these deals")=%%
<br>single variable: %%=v(@intro)=%%
#OUTPUT
inline: Hello! Check out these deals
single variable: Hello! Check out these deals
or
inline: Hello, Adam! Check out these deals
single variable: Hello, Adam! Check out these deals
@nburggraf
Copy link

You should maybe use a ProperCase function for the @firstname variable...Unless your user input is auto-corrected at point of entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment