Hi,
I have a front end table which is data from two Retool DB tables (contacts and organisations), with the organisation name being grabbed by a foreign key on the contacts table. Previously I was just loading data from a single table (contacts) and could use the Bulk update via primary key to handle multiple updates to the data. The .changesArray object always contained the pk and any changed key:values
Now however, when I make any change to data in the UI, I find that the primary key of the contacts table is not in the .changesArray object so any updates to the table fail.
Screenshots of the select statement and changesArray object after a change. Anyone have ideas on this? Do I need to use SQL mode instead of GUI mode?
While I have your very helpful attention, do you know if there's a standard way to use Bulk update via primary key when I update a field from another table? In this instance, say I change the Companies value, the .changesArray has organisation_name and the id, but what I actually want to update is the fk_contacts_organisations field.
Hi, i dont know if there is a standard way to achieve that
but what i do is
i set the fk column to be editable, so when i made changes the chagesetArray will contain the fk value and not the label
Thanks for the guidance. I'm part way there following your advice above but I think I'm still missing something. I have made fk_contacts_organisations editable, and the mapped value is {{contacts.data[i].organisation_name}}. This looks good in the UI.
However, when I change the organisation, the organisation_name is in the .changesArray object. I can understand why, but not sure how to sort of reverse map it so that the FK integer value is in the object instead.
I have added the org name (as well as ID) to the query, but I don't see the same Mapped options as in your screenshot. I can only set a Mapped value.
The datasource of the table is loadContactsDB and highlighted are the available options on the field org_id which is pk of the related organisation. I must be missing something?
Thank you so much for bearing with me @Oscar_Ortega !
I got it to work (finally )
This is super helpful and I will need to use this approach on a number of Apps and functions in the near future. We're just in the process of onboarding.