IsNull Function

The IsNull function returns a value of true or falseonly works with Data Extension fields. If you want to evaluate a string, use the Empty function.

Example:

Performing a Lookup on a data extension field for First Name.

					

%%[
set @firstName = Lookup(‘Data_Extension’,’FirstName’,’Email’,’hello@ampscript.com’)

IF IsNull(@firstName) == ‘true’ THEN
set @firstName = ‘Customer’
ENDIF

]%%
%%=v(@firstName)=%%

Output:

(Depends on data extension value)

Explanation:

A Lookup is performed on a data extension to retrieve the First Name value. The IsNull function is wrapped in an IF statement to display ‘Customer’ if the @firstName value is null. Depending on your use case, the Empty function may work better

Leave a Reply

Your email address will not be published. Required fields are marked *