Picking specific values from the .recordUpdates property

Including only the fields you want updated

If you want to make sure only certain fields get updated for performance or safety reasons do this. Be sure to include the primary key in the array.

{{tblInvoices.recordUpdates.map(row => _.pick(row, ["invoice_id",'status_id']))}}

Excluding columns from update

If your query is from a join and you have columns that are not part of the table you are updating, you need to strip them out.

{{tblProducts.recordUpdates.map(row => _.omit(row, ["product_type","town_name"]))}}

Both of these tips make use of Lodash, which comes preinstalled with Retool.

(from @bradlymathews)

3 Likes

Is there a way to add default values to a column in this scenario?
I want to get the updated values from some columns but then hard code some other values for particular columns.
Thanks

There might be a more elegant one-liner to do this right in your query, but I usually create a transformer that does this. Google something like Adding a property all object in an array and you will get some good direction.

This is exactly what I was looking for. Thank you.

How do i use this code or where do I use it?

I am trying to use this to update a table which is using a join in my query. However 0 I only need to update on column from one table, so I thought the .pick code might work:

> {{tbl_esrs_sector_issues_matching.recordUpdates.map(row => _.pick(row, ["id","required"]))}}

However - when I add this code to a query - it gives me an error, as it doesn't like the square bracket ( [ )

thanks
Neil

It's ok, I have this figure out now......

1 Like