How do I hide Google Forms entry form Gmail if "no data"?
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.
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]
# 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!