Skip to main content

Hi everyone!

I'm seeking assistance with my latest Zap. We have a Google Form with multiple fields that the team uses to place orders from different suppliers. We’ve set up a Zap that emails the supplier based on the form entry.

How can I filter the email so that it only includes items with data? For example, if a field has data (like in the first red circle), it should be displayed in the email. However, if a field is blank (like the second red circle), I want the Zap to remove that entire line, so the supplier only receives a list of needed items, not the entire form.

 

Much appreciated

 

 

Hi @msaad599 

One option is to use Paths for different email templates: https://help.zapier.com/hc/en-us/articles/8496288555917

 

Another option is to use Code to generate the email body content dynamically based on conditions: https://zapier.com/apps/code/help


Hi @msaad599 👋

How did you get on with Troy’s suggestions here, did a Paths or Code action do the trick? If so, we’d love to know which one you ended up using.

And if you hit any snags in trying out either of those options just let us know and we’ll be happy to assist further. 

Looking forward to hearing from you!


Hey @Troy Tessalone, thanks for the suggestion! I ended up using code to get the job done. Although I’m not very familiar with Python, I used an AI generator to help me get started and made some adjustments along the way. Here’s the code I used—hopefully, it can help others too:

# Initialize an empty list to hold the email body lines
email_body_lines = n]

# Define the products and their corresponding quantities
products = {
"Product 1": input_data.get('pro1', ''),
"Product 2": input_data.get('pro2', ''),
"Product 3": input_data.get('pro3', ''),
"Product 4": input_data.get('pro4', ''),
"Product 5": input_data.get('pro5', ''),
"Product 6": input_data.get('pro6', ''),
"Product 7": input_data.get('pro7', ''),
"Product 8": input_data.get('pro8', ''),
"Product 9": input_data.get('pro9', ''),
"Product 10": input_data.get('pro10', ''),
"Product 11": input_data.get('pro11', ''),
"Product 12": input_data.get('pro12', ''),
"Product 13": input_data.get('pro13', ''),
"Product 14": input_data.get('pro14', ''),
"Product 15": input_data.get('pro15', ''),
"Product 16": input_data.get('pro16', ''),
"Product 17": input_data.get('pro17', ''),
"Product 18": input_data.get('pro18', ''),
"Product 19": input_data.get('pro19', ''),
"Product 20": input_data.get('pro20', ''),
"Product 21": input_data.get('pro21', ''),
"Product 22": input_data.get('pro22', ''),
"Product 23": input_data.get('pro23', ''),
"Product 24": input_data.get('pro24', ''),
"Product 25": input_data.get('pro25', ''),
"Product 26": input_data.get('pro26', ''),
"Product 27": input_data.get('pro27', ''),
"Product 28": input_data.get('pro28', ''),
"Product 29": input_data.get('pro29', '')
}

# Iterate through the products and their quantities
for quantity in products.values():
# Extract the quantity from the string
quantity_value = quantity.split(':')t-1].strip() # Get the part after the last colon
if quantity_value.isdigit() and int(quantity_value) > 0: # Only include products with a quantity greater than 0
email_body_lines.append(quantity)

# Join the lines to form the final email body
email_body = "\n".join(email_body_lines)

# Prepare the output with the constructed email body
output = {'email_body': email_body}

 

Here is a screenshot of the Input Data 

 

Here is a screenshot of the email step

 

Thanks for the follow up @SamB, I’m open to any feedback or suggestions on improving this approach.


Yay! That’s fantastic news @msaad599 🎉🎉🎉 

Thank you so much for sharing the code and screenshots of the set up you used. 🤗 This will be super helpful to others that come across this thread in future! Big shout out to @Troy Tessalone for pointing you in the right direction on this! 🧡

Looks like the code you’ve used seems to do the job well enough, no suggestions from my end for edits you’d need to make. Great work on getting this sorted! 🙌

If there’s anything further the Community can help with please do reach back out and until then, happy Zapping!


Reply