I've been reading Zapier documentation using python and they show this example:
output= {'has_lunch': False}
if input.get('body') and 'lunch' in input['body']:
output['has_lunch'] = True
Actually this looks like something that I am looking for, the main difference between the example and my code is that I would like to pass more than one parameters and evaluate those paratemeters to obtein an specific output.
For example:
output= {'Mango': 1, 'Apple': 2}
if input.get('Fruits') and 'Mango' in input['Fruits']:
output['Mango'] = 1
elif input.get('Fruits') and 'Apple' in input['Fruits']:
output['Apple'] = 2
Error: output missing Please define output or return early.
I think this is what you need:
if input.get('Fruits') and 'Mango' in input['Fruits']:
mango = 1
else: mango = None
if input.get('Fruits') and 'Apple' in input['Fruits']:
apple = 2
else: apple = None
output = {'mango': mango, 'apple': apple}
It says Error: output missing Please define output or return early
due to how zapier is setup. In JS you can either do output
or do an if/else and do a return
. I'm no expert in Python, but you would need to use the equivalent of return
in JS for your code to work, otherwise it will stop the function upon reaching the first output
.