I am new to Retool / JavaScript. I am attempting to follow the tutorial [here] (Adding a new record to your database or API) and per the documentation I am attempting to use {{table1.newRow.*}}
(where * is a field name) for each of the fields in my changeset. I am not able to get this to work, however, it appears I am able to access the fields using {{table1.addRow.data.*}}
. Should I be using the .data method or should I not need that?
That's interesting, @daccorti – I'm working on this locally and I'm seeing the properties not be nested in a .data
property (as the documentation says). Can you send over a screenshot of what you're seeing, as well as your table settings for the new row addition?
@justin - I've changed the scope of my query slightly. I am now attempting to update an existing record
using the GUI mode and specifying the field I want to change in the changeset section of the editor. I am facing essentially the same issue though where the .data property does not seem to have access to the fields in my table. See below for the screenshot
Thanks @justin - That works for the bulk update query!
- I was also wondering if I didn't want to bulk update via primary key on the table and just wanted to use the update a record, or create a new record if it doesn't exist
action type, how can I specify that I want to pass updates to only the changed cells and retain the current values for unchanged cells.
e.g. if we have this table
fieldA fieldB fieldC fieldD
A B C D
AA BB CC DE
and a user wants to edit cell (2,4) by clicking into that cell, changing the value, and clicking "save changes" such that our table now looks like this:
fieldA fieldB fieldC fieldD
A B C D
AA BB CC DD
What I currently have:
Filter By:
fieldA = {{table1.selectedRow.data.fieldA}}
fieldB = {{table1.selectedRow.data.fieldB}}
changeset: Key-Value Pairs:
fieldA = {{table1.recordUpdates.fieldA}}
fieldB = {{table1.recordUpdates.fieldB}}
fieldC = {{table1.recordUpdates.fieldC}}
fieldD = {{table1.recordUpdates.fieldD}}
The filters operate correctly, but the generated update query returns something like this:
(! error)
update retool-test-table
set
fieldA = NULL
fieldB = NULL
fieldC = NULL
fieldD = NULL
where fieldA = xx and fieldB = xx
- Parameter types must be provided for null values via the 'types' field in query options.
`