Velocity Macros for Empty String or Null

Am trying to write a Salesforce Data Action that searches for any duplicate records and this needs to be consumed using a dialer.
The problem I am having is that I need to pass several possible columns from the dialer and search to see if we get more than one match. I need to conditionally include the SOQL WHERE statement so that it only searches if the value is not blank. For example we are looking for any duplicates where a customer email may appear on other leads, or their website may be the same etc.
So we created the Data Action something like,

SELECT id FROM Lead WHERE #if(${input.Email})Email LIKE'${input.Email}' OR#end#if(${input.Website}) Website LIKE '${input.Website}'#end

This works ok in the Data Actions when we test and have not entered any values but when we pass them from the dialer columns (which appear to be blank strings the velocity macro ends up searching for any Emails='' (rather than omitting the entire query) which of course matches any customer that has not entered any emails.

With the dialer we can only run a maximum of 2 data actions and we have to check about 5 columns so I cannot run these as separate queries.

Even when I check for a blank or Null in the Dialer Rules, the check fails, so wondering if anyone knows what a blank field from Salesforce looks like and how we can check for that in a either the rule management or the Velocity Macro

Hi Troy!

Based on the last response on this page:

This seems to work

SELECT id FROM Lead WHERE #if($input.Email && !$input.Email.empty)Email LIKE'${input.Email}' OR#end#if(${input.Website}) Website LIKE '${input.Website}'#end"

--Jason

Thank you so much for your quick reply. Worked a treat !!