APIs & Integrations

dev1
Member | Diamond Partner
Member | Diamond Partner

Need to access js variable inside the {% set %} tag

Hello,

We need to get the HubDB row using a js variable which contains the HubDB row id like as below:

var Type = $(‘select[name=“type”]’).val(); //returns HubDB row hs_id value

{% set instances = hubdb_table_rows(table_id, 'hs_id='Type ) %}

But we are not able to done. But if we want to access the twig variable inside js file we are able to that.

Please guide us to use the js variable inside the twig set code.

Thanks.

0 Upvotes
1 Reply 1
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Need to access js variable inside the {% set %} tag

Hi @dev1penguin,

This isn’t possible, since HubL is evaluated server-side before being served up to the client. You’d need to either send the user to a new page when you have the relevant hs_id or use the HubDB HTTP API:

https://developers.hubspot.com/docs/methods/hubdb/hubdb_overview

0 Upvotes