I’m tryin to create a query where I want to get some recipes from a HubDB. Contacts can have 1 or more meal preference and I want to look up recipes with their preference. meal_tag is a select field.
{% set diet_list = contact.meal_preference|split(‘,’) %}
{% set diet_query = “limit=5&meal_tag=” + diet_list|join(‘,’)|lower %}
{% set recipes = hubdb_table_rows(‘ID’, diet_query) %}
But I can not publish this, because I get the following error:
"no such option named ‘{{contact.meal_preference}}’ in column ‘dietary_tag’ "
when I just print ‘diet_query’ I get: ‘limit=5&meal_tag=vlees,vis’
When I use it like this:
{% set recipes = hubdb_table_rows(‘1189000399’, ‘limit=5&meal_tag__in=vlees,vis’) %}
it works, so there is nothing wrong with the content of that variable. But it looks like it is not being rendered.
What can I do to make this work?
You missed the __in operator in your variable definition. Update it to:
{% set diet_query = "limit=5&meal_tag__in=" + diet_list|join(',')|lower %}
Your print output (meal_tag=vlees,vis) shows that you are using the standard equals operator. This causes HubDB to search for an option exactly named “vlees,vis,” which does not exist.