Write a calculated value to database

Hi - new to Retool. I have a table with two fields each containing numbers and a third field which I have set to calculate the product of multiplying the first two numbers - all good and it works when I edit the numbers in the table and save the changes. But ... the calculated field isn't writing back to the database. I gathered that additional calculated columns aren't part of the bulk update by ID GUI function ... so I added the multiplication formula into the actual column (and it looks like it is working as it updates AFTER I press the save changes button) but it obv isnn't writing back as it only updates after the bulk update has executed. How do I get the calculated result to write back to the database?
Huge thanks in advance

Can you share a screenshot of the table and the GUI config...

Hi ... so, the table looks like this...

It runs query7 to populate it with data.
When a cell is changed, it runs query 8 which puts the changed values back to the table.
The issue is that the column in the table that multiplies the first two numbers together looks like it is working because i set the mapped value to
{{currentRow.Y7groups * currentRow.Y7classes}}
... but the table doesn't recognise this mapped value as a changed value and so it isnt sitting in the array that writes back via the bulk update in query8

Essentially (and i don't mind if i have to do it a different way) ... i just need to be able to edit a value in the table, that then updates a calculated column, and that then writes back all changed values to the record.

Hey @bricesm! This is a great question.

Could you try adding a map statement to recordUpdates to manually add the custom column to your record updates info?

Something like:

{{ table1.recordUpdates.map(obj => Object.assign(obj, {'custom1': obj.id*10})) }}

or in your example, something more like:

{{ table2.recordUpdates.map(obj => Object.assign(obj, {'Y7sessionreq': obj.Y7groups * obj.Y7classes})) }}

Let me know if this helps!

Superb - that worked. Thanks :slight_smile: