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.
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
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.
Gotcha, Is it possible to use that token in the flow-step and skip that email?
The Velocity token? No, Velocity never works in Flow steps, period. You'd use the standard Smart List filters: Has Object, constraining on the field value.
@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
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.