CMS Development

ben-duchy
Stratege/Strategin

How to Filter HubDB based on select list

lösung

I currently have a select list with 4 options:

  1. Available
  2. Unavailable
  3. Reserved
  4. Sold

I have managed to filter the table so each row will only display if Available is selected.

 

{% set table = hubdb_table_rows(module.table_id, "&status=Available") %}

 

Is it possible have an 'or' option on the filter for example 'only show if the status is Available or Reserved' ?

0 Upvotes
2 Akzeptierte Lösungen
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

How to Filter HubDB based on select list

lösung

Hi @ben-duchy,

 

You could include multiple options from a "Select" column using the "in" filter. Just for reference we have documentation on the HubL syntax here: https://designers.hubspot.com/docs/tools/hubdb. And the supported filters are documented here: https://developers.hubspot.com/docs/methods/hubdb/v2/get_table_rows.

 

So for example if your column's name is "availability", you could run your filter like this:

 

{% for row in hubdb_table_rows(<tableId>, "availability__in=Reserved,Sold") %}
  <p>The availability for {{ row.name }} is {{ row.availability.name }}.</p>
{% endfor %}

 

That will print out the rows that have the options you've selected in your "Select" column. Hope that helps! Let me know if you have questions.

 

Leland Scanlan

HubSpot Developer Support

Lösung in ursprünglichem Beitrag anzeigen

ben-duchy
Lösung
Stratege/Strategin

How to Filter HubDB based on select list

lösung

Hi @lscanlan,

 

Yes you're right, I figured this out a couple of days ago...

 

{% set table = hubdb_table_rows(module.table_id, "&status__in=Available,Reserved&orderBy=status&orderBy=class") %}

 

Works perfectly! Smiley (fröhlich)

Lösung in ursprünglichem Beitrag anzeigen

0 Upvotes
3 Antworten
lscanlan
Lösung
HubSpot-Alumnus/Alumna
HubSpot-Alumnus/Alumna

How to Filter HubDB based on select list

lösung

Hi @ben-duchy,

 

You could include multiple options from a "Select" column using the "in" filter. Just for reference we have documentation on the HubL syntax here: https://designers.hubspot.com/docs/tools/hubdb. And the supported filters are documented here: https://developers.hubspot.com/docs/methods/hubdb/v2/get_table_rows.

 

So for example if your column's name is "availability", you could run your filter like this:

 

{% for row in hubdb_table_rows(<tableId>, "availability__in=Reserved,Sold") %}
  <p>The availability for {{ row.name }} is {{ row.availability.name }}.</p>
{% endfor %}

 

That will print out the rows that have the options you've selected in your "Select" column. Hope that helps! Let me know if you have questions.

 

Leland Scanlan

HubSpot Developer Support
Graham_USMC
Mitwirkender/Mitwirkende | Partner
Mitwirkender/Mitwirkende | Partner

How to Filter HubDB based on select list

lösung

Thank you @lscanlan - This helped tremendously! It would be fantastical if there were more examples/explination (for us non-hard core coders) on filters page (https://legacydocs.hubspot.com/docs/methods/hubdb/v2/get_table_rows)

ben-duchy
Lösung
Stratege/Strategin

How to Filter HubDB based on select list

lösung

Hi @lscanlan,

 

Yes you're right, I figured this out a couple of days ago...

 

{% set table = hubdb_table_rows(module.table_id, "&status__in=Available,Reserved&orderBy=status&orderBy=class") %}

 

Works perfectly! Smiley (fröhlich)

0 Upvotes