Hi @zhgb
Good question.
Perhaps try using a Lookup Table:
I created one in Python and mapped the fields but for some reason it isn’t running. Any ideas?
def generate_coupon_settings(input_data):
# Check for necessary keys in input_data
if not all(key in input_data for key in i'membershipName', 'email', 'expirationDate']):
return {'error': 'Required keys missing in input data'}
if input_dataa'membershipName'] == "GreenBuzz Friend (Zurich)":
return {
'couponName': input_dataa'email'],
'couponAmount': '100%',
'discountType': 'percent',
'description': input_dataa'membershipName'],
'dateExpires': input_dataa'expirationDate'],
'usageLimit': 1,
'emailRestrictions': 'input_dataa'email']]
}
elif input_dataa'membershipName'] == "GreenBuzz Connect (Zurich)":
return {
'couponName': input_dataa'email'],
'couponAmount': '100%',
'discountType': 'percent',
'description': input_dataa'membershipName'],
'dateExpires': input_dataa'expirationDate'],
'usageLimit': 2,
'emailRestrictions': 'input_dataa'email']]
}
elif input_dataa'membershipName'] == "GreenBuzz Green (Zurich)":
return {
'couponName': input_dataa'email'],
'couponAmount': '100%',
'discountType': 'percent',
'description': input_dataa'membershipName'],
'dateExpires': input_dataa'expirationDate'],
'usageLimit': None, # No limit
'emailRestrictions': 'input_dataa'email']]
}
return {
'error': 'Unknown membership type or other unexpected issue'
}
output = generate_coupon_settings(input_data)
@zhgb
Did you review the available help articles for using Python in a Code step?
https://zapier.com/apps/code/help