<?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 selectattr with variable value seems to have a bug in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723517#M31611</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I struggling with this seemingly simple script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set rows = hubdb_table_rows(XXXX) %}&lt;/P&gt;&lt;P&gt;{% set test = hubdb_table_row(XXXX,YYYY) %}&lt;BR /&gt;{% set queryValue = test.title %}&lt;/P&gt;&lt;P&gt;{% set match = rows|selectattr('title','eq', queryValue ) %}&lt;/P&gt;&lt;P&gt;{{ match }}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;renders: []&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I create a collection by getting the table rows.&lt;/P&gt;&lt;P&gt;I get a single row in the test variable, from the same table.&lt;/P&gt;&lt;P&gt;I take the value of one property of that row&lt;/P&gt;&lt;P&gt;I use that value to filter the rows and find that one row. In theory this should return at least the one row that I fetched in 'test', but it returns nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not my real use case, just an illustration of what I think is a bug. In my real case I'm not setting the queryValue to a value that I fetched from the row. It is a different one and I want to find the rows that match. This is just an illustration that selectattr seems to break when the last argument is a variable.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 10:26:22 GMT</pubDate>
    <dc:creator>PDeT</dc:creator>
    <dc:date>2022-11-28T10:26:22Z</dc:date>
    <item>
      <title>selectattr with variable value seems to have a bug</title>
      <link>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723517#M31611</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I struggling with this seemingly simple script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{% set rows = hubdb_table_rows(XXXX) %}&lt;/P&gt;&lt;P&gt;{% set test = hubdb_table_row(XXXX,YYYY) %}&lt;BR /&gt;{% set queryValue = test.title %}&lt;/P&gt;&lt;P&gt;{% set match = rows|selectattr('title','eq', queryValue ) %}&lt;/P&gt;&lt;P&gt;{{ match }}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;renders: []&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I create a collection by getting the table rows.&lt;/P&gt;&lt;P&gt;I get a single row in the test variable, from the same table.&lt;/P&gt;&lt;P&gt;I take the value of one property of that row&lt;/P&gt;&lt;P&gt;I use that value to filter the rows and find that one row. In theory this should return at least the one row that I fetched in 'test', but it returns nothing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not my real use case, just an illustration of what I think is a bug. In my real case I'm not setting the queryValue to a value that I fetched from the row. It is a different one and I want to find the rows that match. This is just an illustration that selectattr seems to break when the last argument is a variable.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 10:26:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723517#M31611</guid>
      <dc:creator>PDeT</dc:creator>
      <dc:date>2022-11-28T10:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: selectattr with variable value seems to have a bug</title>
      <link>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723542#M31612</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A class="" href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/286738" target="_self"&gt;&lt;SPAN class=""&gt;PDeT,&lt;/SPAN&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;test variable stored the set of records. you need to print test variable. so you will see, that's not a title but it's a rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="css"&gt;{# get all hubDB records at rows #}
{% set rows = hubdb_table_rows(5630042,93304468552) %}

{% set test = hubdb_table_rows(5630042,93304468553) %}
{% set queryValue = test[0].name %} {# OUTPUT Pratik #}


{# test variable get set of row. so you need to select specific row. test object stored [{},{},{}] of records. #}
{% set match = rows|selectattr('name','eq', queryValue ) %}

&amp;lt;pre&amp;gt;
    queryValue - {{ queryValue }} 
    match - {{ match }}
&amp;lt;/pre&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp;&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;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot at Nov 28 16-40-03.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/80044i7AE2342A291D63EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot at Nov 28 16-40-03.png" alt="Screenshot at Nov 28 16-40-03.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot at Nov 28 16-42-41.png" style="width: 703px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/80043i58760A30CE050F6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot at Nov 28 16-42-41.png" alt="Screenshot at Nov 28 16-42-41.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 11:14:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723542#M31612</guid>
      <dc:creator>2CUBE-Studio</dc:creator>
      <dc:date>2022-11-28T11:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: selectattr with variable value seems to have a bug</title>
      <link>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723812#M31627</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/483218"&gt;@2CUBE-Studio&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my example, the test is filled from hubdb_table_row which is a different function from your example hubdb_table_rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, a lot more debugging later, it appears to be a data issue (and a hubl issue). For some records taking the title and then running a selectattr with that title returns no results, for others, it worked. So depending on the value of YYYY I had sometimes normal results and sometimes no result.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;This is a bug imho, although a different one then I initially thought. If you take the value of a property of a row as the value for a filter on that same property, you should at least get the row from which it was taken as a result. An empty result is broken math &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Probably there happens some sanitation of some sort on the value, which then causes it not to match anymore with the original value, resulting in an empty match collection. I haven't found the possible cause for this. At first I thought it could be the space in the string, but another record which also had a space in the title field worked fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll go back to my client and pressure them a little harder to not try to match on titles but on id's, which I hope will have fewer problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pieter&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 20:14:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/selectattr-with-variable-value-seems-to-have-a-bug/m-p/723812#M31627</guid>
      <dc:creator>PDeT</dc:creator>
      <dc:date>2022-11-28T20:14:51Z</dc:date>
    </item>
  </channel>
</rss>

