CMS Development

merel
Participant

Accessing HubDB foreign row data

SOLVE

I used this tutorial to create this page for a client, and I'd like the firm logos to live in a separate database so they can be easily updated, and used in multiple instances. I've created the firm logo database and linked it to the main one via a foreign ID column, but I can't figure out how to access all of the foreign table data. I've tried the nested for loop recommended in How to Join HubDB Tables:

 

{% for row in hubdb_table_rows(<tableId>) %}
  the name for row {{ row.hs_id }} is {{ row.name }}
  {% for foreign_row in row.foreign_table %}
  	the name for foreign row {{ foreign_row.hs_id }} is {{ foreign_row.name }}
  {% endfor %}
{% endfor %}

 And I get this output, with none of the foreign table rows.

I'm pretty new to HubL and databases, so I'm sure there is something basic I am missing. I have poured over the documentation for HubDB and just can't figure it out. Any help would be greatly appreciated!

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Accessing HubDB foreign row data

SOLVE

Is your foregin id column's internal name foreign_table? If not you need to change foreign_table to the internal name of your foreign id column.

 

{% for foreign_row in row.foreign_table %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

2 Replies 2
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Accessing HubDB foreign row data

SOLVE

Is your foregin id column's internal name foreign_table? If not you need to change foreign_table to the internal name of your foreign id column.

 

{% for foreign_row in row.foreign_table %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
merel
Participant

Accessing HubDB foreign row data

SOLVE

I knew there was something simple I was missing! Thanks!

0 Upvotes