Unable to access HubDB column type via HubL


Hi all,


I'm attempting to access the table information of a HubDB table to create a client-side JS map object of column IDs to column labels in order to simplify my code, like so ::

{% set table_info = hubdb_table(table_id) %}
{% for col in table_info.columns %}
    console.log("{{ col.type|string }}");
    col_map['{{ col.name }}'] = {};
    col_map['{{ col.name }}'].id = '{{ col.id }}';
    col_map['{{ col.name }}'].type == "{{ col.type }}";
    {% if col|attr('type') == 'SELECT' %}
        col_map['{{ col.name }}'].options == {{ col[options] }};
    {% endif %}
{% endfor %}

I believe the output of the function could be erroneous. I can access the attributes 'id' and 'name' using any of the above methods, but I cannot access 'type'. I've tried {{ col.type }}, {{ col|attr('type') }} {{ col['type'] }}, {{ col[type] }}, none work, all just give blank output. I also tried using the string filter :: {{ col.type|string }}, which returned 'null'. On inspecting the output using the console, I observed that the type attribute seems to be a constant or similar, as its not wrapped in single quotes in the same way that the 'name' attribute is :: 

{name='heading', label=Heading, type=TEXT, id=1, deleted=false, options=[], width=null}

Is this by design? If so, other than using JS/JQ string functions / regex-ing to parse, can anybody suggest a more streamlined mechanism to access? Speed is of concern as my code is client-side and is executing at render-time.


Thanks in advance for any assistance.

2 Replies 2
HubSpot Product Team

Hey @kfischmann sorry for the lack of response here. Are you still having trouble? If so I'll see if we can get a member of our product team to help 🙂


Hi @roisinkirby, all sorted! I headed over to integrate.hubspot.com and opened a thread there also.


For those interested, here is the response.