<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem when filtering a HubDB query with a custom module field in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/10297#M1069</link>
    <description>&lt;P&gt;How do you acheave this but with THE TABLE ID being&amp;nbsp;dinamic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set queryparam = "&amp;amp;orderBy=order" %}&lt;/P&gt;&lt;P&gt;{% set tableid = "widget.table_id" %} /* table id can change from page to page */&lt;/P&gt;&lt;P&gt;{% for row in hubdb_table_rows( tableid , queryparam )%}&lt;/P&gt;&lt;P&gt;&amp;nbsp;content here&lt;BR /&gt;{% endfor %}&lt;/P&gt;</description>
    <pubDate>Sun, 26 Mar 2017 15:48:01 GMT</pubDate>
    <dc:creator>adriancblack</dc:creator>
    <dc:date>2017-03-26T15:48:01Z</dc:date>
    <item>
      <title>Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1055#M81</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to add a filter to a HubDB query, using the content from a text&amp;nbsp;field in a cusom module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my custom module, I have the following code, wich works fine:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% for row in hubdb_table_rows(table_id,"&amp;amp;partner__eq=3") %}&lt;BR /&gt;Print Something&lt;BR /&gt;{%endfor%}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the "3" to be dinamically set on each different page. For that, I'm using a Text Field on the Custom module.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would expect that something like this would work:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;{% for row in hubdb_table_rows(&lt;/SPAN&gt;&lt;SPAN&gt;table_id&lt;/SPAN&gt;&lt;SPAN&gt;,"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;amp;partner__eq="~widget.partner_number) %}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Print Something &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{%endfor%}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But this, or any variant form of concatenating the string with the field content, gives me the same result:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"The following validation error was found:"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;With no extra detail.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I even tried to do domething like this, wich works:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;{% set partner_number="3"%}&lt;BR /&gt;{% set pre_filter="&amp;amp;partner__eq="%}&lt;BR /&gt;{% set filter= pre_filter ~ partner_number %}&lt;/P&gt;&lt;P&gt;{% for row in hubdb_table_rows(155348,&lt;SPAN&gt;filter&lt;/SPAN&gt;) %}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I change the "3" with&amp;nbsp;&lt;SPAN&gt;widget.partner_number, it gives the same error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anyone has any idea what it might be the problem?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2016 18:58:53 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1055#M81</guid>
      <dc:creator>Mohva</dc:creator>
      <dc:date>2016-11-17T18:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1113#M95</link>
      <description>&lt;P&gt;I set up all my queries outside of that for loop, like you are showing at the bottom.&lt;/P&gt;&lt;PRE&gt;{% set queryparams = "" %} &lt;BR /&gt;{% if request.query_dict.fname %} &lt;BR /&gt;    {% set queryparams = queryparams ~ "&amp;amp;fname="~request.query_dict.fname|title|urlencode %} &lt;BR /&gt;{% endif %}&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 12:58:42 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1113#M95</guid>
      <dc:creator>nickdeckerdevs</dc:creator>
      <dc:date>2016-11-18T12:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1118#M96</link>
      <description>&lt;P&gt;Not sure what did the trick, but it worked like a charm.&lt;/P&gt;&lt;P&gt;Here is the code I implemented, using yours as base:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set queryparams = "" %}&lt;BR /&gt;{% if widget.partner_number %}&lt;BR /&gt;{% set queryparams = queryparams ~ "&amp;amp;partner__eq="~widget.partner_number|title|urlencode %}&lt;BR /&gt;{% endif %}&lt;/P&gt;&lt;P&gt;{% for row in hubdb_table_rows(tableid, queryparams ) %}&lt;/P&gt;&lt;P&gt;Print Something&lt;/P&gt;&lt;P&gt;{% endfor %}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2016 13:32:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1118#M96</guid>
      <dc:creator>Mohva</dc:creator>
      <dc:date>2016-11-18T13:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1130#M98</link>
      <description>&lt;P&gt;I'm glad you got it working. A few tips:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;"__eq" is the default comparison operator, so you can just use "partner=".&lt;/LI&gt;&lt;LI&gt;You don't need to start the query with an '&amp;amp;'. It should still work, but it's unnecessary.&lt;/LI&gt;&lt;LI&gt;If partner_number is really just a number, you don't the title or urlencode filters.&lt;/LI&gt;&lt;LI&gt;Nick is correct in that you do have to build the query string before the hubdb_rable_rows call.&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Fri, 18 Nov 2016 15:15:13 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/1130#M98</guid>
      <dc:creator>boulter</dc:creator>
      <dc:date>2016-11-18T15:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/10297#M1069</link>
      <description>&lt;P&gt;How do you acheave this but with THE TABLE ID being&amp;nbsp;dinamic?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set queryparam = "&amp;amp;orderBy=order" %}&lt;/P&gt;&lt;P&gt;{% set tableid = "widget.table_id" %} /* table id can change from page to page */&lt;/P&gt;&lt;P&gt;{% for row in hubdb_table_rows( tableid , queryparam )%}&lt;/P&gt;&lt;P&gt;&amp;nbsp;content here&lt;BR /&gt;{% endfor %}&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2017 15:48:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/10297#M1069</guid>
      <dc:creator>adriancblack</dc:creator>
      <dc:date>2017-03-26T15:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem when filtering a HubDB query with a custom module field</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/10364#M1077</link>
      <description>&lt;P&gt;In my case, the table_id is always the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can imagine different ways you can make it dynamic. If the change occurs in the page level, you can create a property on a Custom Module that allows you to set the related table_id for each page.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need to be dynamic within the page, you will have to put a Hubl variable with all the tables ids available and make your algorithm from there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or if your tables will be changin, maybe is better to use te REST API and process the tables using Javascript (&lt;A href="http://developers.hubspot.com/docs/methods/hubdb/get_tables" target="_blank"&gt;http://developers.hubspot.com/docs/methods/hubdb/get_tables&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But in that case, you have to be more carefull since you'll have to go throught authentication, so you probably don't wan't to expose that to the general public.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 17:44:56 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Problem-when-filtering-a-HubDB-query-with-a-custom-module-field/m-p/10364#M1077</guid>
      <dc:creator>Mohva</dc:creator>
      <dc:date>2017-03-27T17:44:56Z</dc:date>
    </item>
  </channel>
</rss>

