I created a rates page on our website and have a HubDB table pulling the data into it. The rates are updated daily. I thought that I could just upload and replace the CSV file onto the HubDB table and it would be good to go but when I upload the new file, the ID numbers are updated within the hubdb table as well - which makes a disconnect to the rates page.
I copied the HTML for the table into a custom module. In the custom module, I added a HubDB field that allows you to select which HubDB field to use in the module. Next, I added a bit of HubL at the top of the custom module to copy all of the row IDs for the selected table to an array/sequence:
{% set row_array = [] %}
{% for row in hubdb_table_rows(module.hubdbtable_field) %}
{{ row_array.append( row.hs_id ) }}
{% endfor %}
Then, in the area of the table that used to reference the values by row ID, I changed the syntax to be more like this:
so now we are referencing the product for the row at index 0 in the array we just made {{ hubdb_table_row( module.hubdbtable_field, row_array[0]).product }} instead of before, where you were referencing specific row numbers {{ hubdb_table_row( 1053882, 21504528746).product }} I did hard code in the row references so the other rows are pulling row_array[1] and row_array[2] , but this should work for your use case, which is that when importing data, the row ids change