Hello there! I want to be able to print out my multi select field called ‘state’ (it was single prior, I’ll change it later lol). My code says ‘Cannot Resolve Property: Name’ when I try to extract the value from my HubDB.
I was able to extract it successfully when I had a single select dropdown, but I need it for multi-select now.
Here is my complete code:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css">
{% set int_state_ID = 1 %}
<!-- set the filter -->
<div>
<form id="form_id" method="get">
<div>
<h2>FILTER BY STATE: </h2>
<select name="state" form="form_id" onChange="this.form.submit()">
<option value="show-all">Show All</option>
{% set states = hubdb_table_column(5440613, "state").options %}
{% for choice in states %}
{% set state_list = state_list~choice.id|list%}
{% if choice.id == request.query_dict.state%}
<option selected="selected" value="{{ choice.id }}">{{ choice.name }}</option>
{% else %}
<option value="{{ choice.id }}">{{ choice.name }}</option>
{% endif %}
{% endfor %}
</select>
<input name="name" type="text" id="search-by" class="autocomplete" placeholder="Search by name...">
</div>
{# <div>
<input name="name" type="text" id="search-by" class="autocomplete" placeholder="Search by name...">
</div> #}
<div class="button button-decor" input id="submit-button" type="submit" value="Search">Search</div>
{# <div class="button button-decor"><input type="button" onclick="location.href='http://21908587.hs-sites.com/uson-local-support';" value="Show All" /></div>
<div class="button button-decor"><input type="button" onclick="location.href='http://21908587.hs-sites.com/uson-local-support-0';" value="View International Consultants" /></div> #}
<div class="button button-decor" onclick="location.href='http://21908587.hs-sites.com/uson-local-support';">Show All</div>
<div class="button button-decor-2" onclick="location.href='http://21908587.hs-sites.com/uson-local-support-0';">View International Consultants</div>
</form>
</div>
<!-- sets the different query parameters using submitted input for hubdb query -->
{% set queryparam = "" %}
{% if request.query_dict.state in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"] and request.query_dict.name == "" %}
{% set queryparam = queryparam ~ "&state=__contains"~request.query_dict.state|urlencode %}
{% endif %}
{% if request.query_dict.state in ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50"] and request.query_dict.name != "" %}
{% set queryparam = queryparam~"&state="~request.query_dict.state|urlencode~"&zip__icontains="~request.query_dict.zip|urlencode %}
{% endif %}
{% if request.query_dict.state == "show-all" and request.query_dict.name != "" %}
{% endif %}
{% set table = hubdb_table_rows(5440613, queryparam) %}
<!-- Check if table exists, set sort by state -->
{% if table == [] %}
<p class='align-center'>Sorry, no listings found for that search. Try changing your filter and search again.</p>
{% else %}
{% for row in table|sort(False, False, 'state') %}
<div class="consultant-listing">
<h2>{{ row["name"] }}</h2>
<div class="information">
{% for row in table %}
{% for state in row.state %}
<div class="fac_state">{{ row.state.name|pprint }} </div>
{% endfor %}
{% endfor %}
<div class="fac_city"">{{ row["city"] }}, {{ row["zip"] }}</div>
<i class="fas fa-phone"></i> {{ row["phone"] }}
<br> <i class="fas fa-link"></i> <a href="{{row["website"]}}">Website</a>
<br><i class="fas fa-envelope"></i> <a href="mailto:{{ row["email"] }}">{{ row["email"] }}</a>
<div class="location_details">{{ row["location_details"] }}</div>
</div>
</div>
{% endfor %}
{% endif %}</div>
row.state.name is printing out null, so there is no value.
When I put down {{row.state}} it renders:
[{id=3, name=‘Arizona’, order=2}, {id=6, name=‘Colorado’, order=5}]
[{id=3, name=‘Arizona’, order=2}, {id=6, name=‘Colorado’, order=5}]
How do I properly extract ‘name’?
Here is a screenshot of my HubDB table. So ‘State’ is multi-select now instead of select. I just want to extract the values of State and render it correctly on the webpage.
I also checked here: https://community.hubspot.com/t5/CMS-Development/How-to-Get-Filtered-Data-From-HubDB-from-Multiple-Select-Column/m-p/257682
…But maybe I need a second pair of eyes to check my code?
Thank you!

