Table update dropdown (Tag) not providing the correct value when other cells are updated

I have a table where a few cells can be updated via tags/dropdown triggered by a cell change. When a dropdown is changed, the changed cell produces the correct option value in recordUpdates[0]. Other dropdown columns are showing the label in recordUpdates[0] rather than the option value.

For example: given two columns updated by dropdown - Employee and Project where the option value is a numeric id and the option label is the string name.
When the Employee is updated, the employee id is listed in recordUpdates[0] successfully, but recordUpdates[0] is displaying the label for Project rather than the value of the currently selected project.

An example of the currently unexpected provided recordUpdate for a change in Employee would be {Employee: 1, Project: 'Test Project'}. The expected recordUpdate would be {Employee: 1, Project: 2}

Hey @paul.narup!

Would you mind sharing a screenshot of the configuration for each of those columns?

@Kabirdas Here's the screenshots. Using two different ways to get the value/label but functionally appears the same

Hey @paul.narup! Just want to post the solution here in case anyone stumbles across this thread.

It looks like basing the Employee and Project columns on the columns you were updating (i.e. USERID and PROJECTID) instead of USER and PROJECT works here. That way Retool fetches the ID as expected instead of the name when you re-query your database after updating. The column settings can otherwise be kept the same.

If there's something I'm missing from the solution or it could be clarified please let me know!

1 Like

@Kabirdas For anyone else who finds this, it appears this solution breaks filtering due to the issues discussed here. Hopefully, table update fixes in the near future. Table filters are not applied on mapped column value - #10 by crhayes

1 Like

Thanks for flagging this @paul.narup!

If you'd like to have the underlying data for that column remain a string, you might try using the table's .changeSet property which stores only the key/value pairs for those columns that have actually changed.

It's structured a bit differently, as an object whose keys are the indexes of the changed rows. But you can use something like Object.values(table.changeSet)[0] to access the first object and also assign it new values using something like Object.assign.