I have a Python function that processes form data from checkboxes. The code should take boolean values and matching labels, then create a list of selected items.
Here’s what I’m working with:
def process_selections(form_data):
selected_items = []
for field_name in form_data:
if form_data[field_name] == True:
print(field_name)
selected_items.append(field_name)
if form_data['Other'] != "":
selected_items.append(form_data['Other'])
output_text = ', '.join(selected_items)
output_text = str(output_text)
return output_text
final_result = process_selections(form_data)
output = print(final_result)
The function works perfectly when I test it in my local Python environment. However, when I run the same code in Zapier’s Python editor, nothing gets returned or displayed. I’ve tried different approaches but still get blank results in Zapier. Has anyone experienced this issue before? What could be causing the difference between local execution and Zapier’s environment?
zapier’s python env only returns values, not prints. ur code is mostly fine, but ditch the print at the end and just do output = final_result. also, make sure form_data is flowing correctly – sometimes data formats mess up in zapier.
Had the same issue last month migrating to Zapier. Yeah, the print statement assignment is your main problem, but there’s another thing that’ll bite you. You’re checking form_data['Other'] every loop iteration - that’s gonna cause duplicates or crash if ‘Other’ isn’t always there. Move that check outside the loop or add a condition to make sure the key exists first. Also heads up - Zapier sometimes sends string booleans instead of actual booleans, so you might need to check for both True and ‘true’ depending on your form. Debugging sucks without print statements in Zapier, so definitely test with sample data first.
Your problem’s in the last line - you’re setting output = print(final_result). Since print() returns None, that’s what your output becomes instead of the actual result. Zapier needs returned values, not printed ones. Just use output = final_result or return the value directly from your function. Also double-check that form_data is properly defined in Zapier’s environment. The data structure often differs from local testing. I’ve hit this same issue where everything worked locally but failed in Zapier because of how variables get passed between steps.