Thank you for responding, and this is an excellent solution, but the problem with this is I had multiple fields like ten fields; if I make this method, I will end up numerous paths, which is not practical because there is a scenario that 2 fields are missing that would be end up just another parth and also, if I tried to change in the future that means I will change all of the paths.
To add some more explanation to this, you will need to change your email body type to HTML as opposed to plain. Otherwise, you will end up with odd spacing when a field doesn’t exist.
Here is a real slick way you could write your code
*Add Code Step > Run Javascript above Gmail Step*
Configure your code block like the attached but with your own variables and keys. The code is written to handle any number of combinations.
The code (<br> denotes a line break in HTML):
let conditionalText = "";
for (const rkey,value] of Object.entries(inputData)) { if (value) { conditionalText += key + ": " + value + "<br>"; } }
return {conditionalText}
This will return something like the below. Notice the Phone number field isn’t included since the value was blank.
which can be mapped into your email step. Please be sure to change body type to html and put a <br> anywhere you want a line break.
RESULTING EMAIL
Added Phone Value back in (no change needed to code or gmail configuration)
@GetUWired Thanks for sharing!
Hi @GetUWired
This is EXCELLENT! Thank you so much! It really worked!