Best answer

Dynamics Fields

  • 30 December 2021
  • 6 replies
  • 95 views

Hi there,

I’m new with this community and I am trying to send data leads from Airtable to Gmail but I wan’t to set a Dynamics fields like for example:

__________________
Airtable Data:

First Name: John
Last Name: Mike
Address:1234

Age:
Email: John@sample.com

________________
Gmail:
 

First Name: {{142106945__John}}
Last Name: {{142106945__Mike}}
Address: {{142106945__1234}}

(Age: - I want to remove this section if empty including the Age label.)
Email: John@sample.com

_________

Thank you.

icon

Best answer by GetUWired 30 December 2021, 17:08

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

6 replies

Userlevel 7
Badge +14

Hi @Clyteroll 

You can use Paths in Zaps: https://zapier.com/help/create/customize/add-branching-logic-to-zaps-with-paths

Paths have Filters: https://zapier.com/apps/filter/help

Hi Tony!

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.

Thank you

Userlevel 7
Badge +14

Hi @Clyteroll 

Then you’ll need to use a Code step to evaluate if the field value exists and return the output: https://zapier.com/apps/code/help

Userlevel 7
Badge +12

Hi @Clyteroll 

 

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 [key,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)

 

Userlevel 7
Badge +14

@GetUWired Thanks for sharing!

Hi @GetUWired 

This is EXCELLENT! Thank you so much! It really worked!

 

Best

Clyteroll C