My team and I frequently encounter this issue with CRMs that have multiple fields for email addresses. Please review the following screenshot:
We are not entirely certain if the 'Home Email' field will always contain an email address, yet the subsequent step requires an email address for this lead/contact. Therefore, here is a tip I use to resolve this situation.
Add a Formatter - Numbers - Spreadsheet-Style Formula step
I use the formula below. Remember, when working with strings or string values in the Spreadsheet-style formula, you must enclose the values in quotes.
if("{{mobile_email}}"="",if("{{home_email}}"="","{{work_email}}","{{home_email}}"),"{{mobile_email}}")
In plain terms, this formula checks if 'mobile_email' is empty. If it is, it then checks if 'home_email' is empty; if both are empty, it uses 'work_email'. If 'mobile_email' is empty but 'home_email' is not, it uses 'home_email'. If 'mobile_email' is not empty, it uses 'mobile_email'.
In its current configuration, this formula does not verify if 'work_email' is empty when all email variables are empty. In such cases, the output of this step would be "" (empty or null). If this happens, we do not have a valid email address. You might consider adding a path/filter in the next step to prevent processing if the output of this formula is empty, thus avoiding attempts to create a contact.
If you wish to check the third variable for an empty state and provide a replacement, you could use this variation of the formula:
if("{{mobile_email}}"="",if("{{home_email}}"="",if("{{work_email}}"="","Value For all three empty","{{work_email}}"),"{{home_email}}"),"{{mobile_email}}")
Nested IF statements can become complex, but they are generally very useful for combining, replacing, or condensing variables based on their values.
This is a great tip, thanks!
It appears something has been updated. I'm encountering an issue while attempting to use this, specifically receiving aFormatter error: Invalid Syntax: Only numeric values are allowed
error. This is happening even when I utilize the Transform text with a spreadsheet-style formula.
action within a text event!