no such option in Hubdb query when using __in

Hi,

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?

Hi @VStruyf,

Are you trying to build a web page module or an email module?

Also, how are you defining the “contact” in this case?

Hi @VStruyf

Thank you for posting your question!

Here’s a Community Thread that has a solution for your issue:

https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1055

I also want to tag a few experts for more ideas. Hey there @nickdeckerdevs @Kevin-C @elizheleva hope you’re having a great week! Any ideas here?

Thanks!

Victor

Thanks! That worked.

Hi @VStruyf,

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.

sorry, that was correct in my code, but wrong here because I neede to change my variable name since it was not allowed here :see_no_evil_monkey:.