How to make an audience skip if a particular field is null using velocity code? | Community
Skip to main content
Level 2
Nov 6, 2019 4:51 AM UTC
Question

How to make an audience skip if a particular field is null using velocity code?

For example if I have a field A from custom object and I'm displaying it in the email content. In-order to neglect those who have null values in that particular field(A) I want to skip it using a velocity code, is this feasible or do I need to do it via campaign or flow setup.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

6 replies

Amit_Jain
Community Manager
Nov 7, 2019 10:14 AM UTC

You have to use a filter in the smart list of the smart campaign to skip the user from receiving the email.  But in case you have multiple flow actions in that smart campaign and you just want to skip this particular flow actions which is sending email, you can create a separate smart list for these users and use that smart list as condition in the flow step like below:

Velocity script can be used to manipulate the email content but it can not skip the email altogether. Hope it will help.

Translate
Level 2
Nov 6, 2019 5:10 AM UTC

@nicholas Thanks for your solution, but I don't want to stop null value instead I want to skip that customer from getting email, so in the else part I need to write a function to skip him from getting email

Translate
Nicholas_Manojl
Level 8
Nov 6, 2019 4:59 AM UTC

I'm not sure I fully understand your question.

#if (customObject.get(0).fieldA)
This only shows if they have a value in fieldA
#end‍‍‍‍‍‍

or potentially you mean, how do I stop the  null value from showing the reference? You can prepend your field reference with an exclamation mark:

$!customObject[0].fieldA

Translate
SanfordWhiteman
Level 10
Nov 6, 2019 5:13 AM UTC
This only shows if they have a value in fieldA

It shows if they have a value other than Boolean false or null in the first entry in the list.

So: not the same as "do they have a non-null in any of the entries in the list".

In order to check that some value is non-null you must iterate over the entire list.

But I think what this thread is about is suppressing the email entirely, which cannot be done with Velocity. It has to be done using Smart List qualification.

Translate
Level 2
Nov 6, 2019 5:17 AM UTC

Gotcha, Is it possible to use that token in the flow-step and skip that email?

Translate