Coloring a table cell color based on the cell selected and a button click

I'm just checking to see if there is a better way to do something then the way I am using.

I have a table that shows all the shipments going out for a certain day. Occasionally the Logistics department like to highlight a cell in a different color in order to bring attention to it. The way that I tried to go about doing this was to have the user click a cell which would then set a variable with the name of the cell to change. Then they would click a button of the color they wanted which would trigger a SQL update:

UPDATE shipping
SET {{ cell_name }}.variable = TRUE

Running this SQL returns a "syntax error at or near "$1"" error. In my research, I have discovered that turning off perpared statments may allow this SQL to work. The problem is that it breaks all my other SQL. Does anyone have any suggestions on how to

  1. work around the prepared statments issue
  2. do what I am trying to do with a better method

I have posted this before, but if I don't figure out how to do this, the entire project may get scrapped.

Hi @tomm! Thanks for reaching out - Let me see if I can provide any help or guidance.

If I'm understanding the situation correctly, you're just trying to change the background color of a Table column based on a dynamic value? One way you can accomplish this is by creating a variable within Retool and leveraging that variable's value within the background value of the column you're trying to change.

Here's a screenshot of what I'm describing:

If you take a look above, you'll see that I created a variable called variable1 with an initial value of BD1111, and on the right-hand side you'll see that I'm using
{{ variable1.value }} to replace the Background color (the red column). This variable value can be manipulated through queries and actions, so I believe this could be a potential workaround for what you're asking.

Please let me know if there are any gaps and I can try to provide more guidance!