i’m trying to pass a HubDB table row id to a page using an URL parameter. The id fetched from request.query_dict will be a string but unfortunately hubdb_table_row() seems to accept only variables of type long.
Is there a way to convert this string into a long so hubdb_table_row() is happy?
The problem is not that the preview is incorrect, but that you’re unable to publish the code in the first place. The error message you get (“TemplateSyntaxException : Error invoking function hubdb_table_row”) isn’t helpful either. You might want to adjust that to prevent other users from having the same issue. At least this thread will help to identify a potential workaround.
{% set rowId = request.query_dict.get('rowId') %}
{% if rowId is undefined %}
{% set rowId = "1" %}
{% endif %}
{% set row = hubdb_table_row(123, rowId) %}
This works fine. The problem seems to be that once I try to publish my code, HubSpot will run the code to do syntax and validation checks. This causes hubdb_table_row() to error out, because request.query_dict.get(‘rowId’) is of course undefined in that context.
If there a way to disable this syntax check on publish?
{% set test1 = 4993770623 %}
{% set test2 = '4993770623' %}
{% set test3 = request.query_dict.get('rowId') %}
test1: value is "{{ test1 }}", type is {{ type(test1) }}<br>
test2: value is "{{ test2 }}", type is {{ type(test2) }}<br>
test3: value is "{{ test3 }}", type is {{ type(test3) }}<br>
Will result in the following output:
test1: value is "4993770623", type is long
test2: value is "4993770623", type is str
test3: value is "4993770623", type is str
test1 and test2 will be accepted by hubdb_table_row(), test3 won’t.
{% set test1 = 4999122222 %}
{% set row1 = hubdb_table_row(123, test1) %}
{% set test2 = request.query_dict.rowId %}
{% set row2 = hubdb_table_row(123, test2) %}
The last line doesn’t work. Apparently there is no way to convert a (large) number string into a number. I’ve tried to type convert the string, however using the |int filter doesn’t work (number is probably too big). You can use test2|abs to convert the string into a BigDecimal type, but again hubdb_table_row refuses that. test2|long doesn’t seem to exist…
@jolt Are you passing information from hubDB to your page or from your page to hubDB? or both? I would love it if you could dive into a little more detail about the entire process.
@jolt Could you parse the string for a number on the page itself? Do you have a link to your page or portal I can check it out on? You can DM the link if you would prefer.