- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Script to let user download a specific table from Hubdb
SOLVEFeb 22, 2020 7:49 PM
Hi Community,
I want users to be able to export a specific hubdb table that is displayed on my site as a CSV file. How is that typically done in hubspot?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Accepted Solutions
Feb 23, 2020 2:34 PM
Hey @imerial ,
You can export the table as a CSV yourself , upload the file to the file manager, and add a link to it on your page. If you want it to be more dynamic and update automatically when the table is updated I don't believe there is any built in functionality for that. You could however use javascript to output the data into an array and create a csv download from that.
https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-si...
Example of outputting HubDB data into a javascript array :
{% set data = hubdb_table_rows('XXXXXX', filters) %} <script> window.products = [ {% for item in data %} { hs_id: {{ item.hs_id|tojson }}, name: {{ item.name|tojson }}, description: {{ item.description|tojson }} }{% if not loop.last %},{% endif %} {% endfor %} ]; </script>
Alyssa Wilie
Web Developer at LyntonWeb
If this answer solved your question, please mark it as the solution!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content