Verification in progress Differs from official docs Test scripts included

Syntax

IsNull(value)  →  boolean
1 argument — exactly

Parameters

Name Type Required Description
value string | number | boolean | date Yes Value to test — typically a data extension field value retrieved with Lookup

In a Next email it also works on page variables: an unset variable or the empty string counts as null.

Example

%%[ VAR @nickname ]%%
%%=IsNull(@nickname)=%%

Renders true, because the variable was declared and never set.

%%[ SET @word = "hello" ]%%
%%=IsNull(@word)=%%

Renders false.

Return value

boolean — true when the value is null or empty, false otherwise.

Written into the email, the result is the lowercase word true or false.

Behaviour

Unset and empty count as null. An undeclared variable, a variable declared with VAR but never set, and a variable set to "" each give true.

Whitespace and zero do not. Whitespace, 0, "0", "false", an ordinary string like "hello" and Now() each give false. So do the literals "x" and 0 passed directly.

v() passes the empty value through. IsNull(v(@unset)) gives true.

Concat with one argument cannot be nested. An email with IsNull(Concat(@unset)) is rejected at save with HTTP 400, “The AMPscript syntax isn’t valid”. That is a Concat rule: it needs at least two arguments in Next.

Data extension fields, subscriber attributes and request parameters were not tested in Next.

Show Next test script
<!-- Marketing Cloud Next test script for IsNull. Paste it into the HTML component of a
     Next email and open the preview. Each line prints the result Next gave when the call
     was rendered on its own (expect) next to the result of this run (got).
     Assembled from single-call test emails (dates on the page); it has not been
     run as one email. Calls that make Next fail are listed separately. -->
<p>c1 expect=[false] got=[%%=IsNull("x")=%%]</p>
<p>c2 expect=[false] got=[%%=IsNull(0)=%%]</p>
<p>c3 expect=[true] got=[%%=IsNull(@r2n_never_declared)=%%]</p>
<p>c4 expect=[true] got=[%%[ VAR @r2nu ]%%%%=IsNull(@r2nu)=%%]</p>
<p>c5 expect=[true] got=[%%[ SET @r2nes = "" ]%%%%=IsNull(@r2nes)=%%]</p>
<p>c6 expect=[false] got=[%%[ SET @r2nsp = "   " ]%%%%=IsNull(@r2nsp)=%%]</p>
<p>c7 expect=[false] got=[%%[ SET @r2nz = 0 ]%%%%=IsNull(@r2nz)=%%]</p>
<p>c8 expect=[false] got=[%%[ SET @r2nz0 = "0" ]%%%%=IsNull(@r2nz0)=%%]</p>
<p>c9 expect=[false] got=[%%[ SET @r2nsf = "false" ]%%%%=IsNull(@r2nsf)=%%]</p>
<p>c10 expect=[false] got=[%%[ SET @r2nval = "hello" ]%%%%=IsNull(@r2nval)=%%]</p>
<p>c11 expect=[false] got=[%%=IsNull(Now())=%%]</p>
<p>c12 expect=[true] got=[%%[ VAR @r2nv ]%%%%=IsNull(v(@r2nv))=%%]</p>

Show calls that fail in Next (one email each)
<!-- Run each call below in its own Next email: one of them in a combined email
     would stop the whole preview or block the save. -->

<!-- email 1: expect that the save is rejected (HTTP 400) -->
%%[ VAR @r2nc ]%%%%=IsNull(Concat(@r2nc))=%%

Differs from official docs

  • The empty string counts as null. The docs say IsNull, unlike Empty, does not treat the empty string as null. In Next a variable set to "" gave true. Card

Availability & differences

PlatformAvailable
Marketing Cloud EngagementYes
Marketing Cloud NextYes, from API 67.0

See also