Dynamic Tag Colors

  • Goal:
    Hi everyone! I need some help, yet again! I have a table component that is fed by a SQL query.
    I have created 2 customs columns:
    A. ProposedFeeValue
    B. Status

The idea is that when column 'ProposedFeeValue' equals another colum called 'FeeValue', the custom column 'Status' shows the value 'OK' and is Green, if not equal, then color in red with the value 'Review' shown:

I've managed to:
Create the custom column
Create a variable to store the red and green colors to the 'ok' and 'review' values:

Variable for colors:
{
OK: "Green",
Review: "Red"
}

Datasource for 'status' column:

{{ currentSourceRow.fee_initial_value === currentSourceRow.proposedFeeValue ? "OK" : "Review" }}

I am a beginner in JS and retool - my challenge is that the column values don't seem to be changing the 'status' column at all.

I'm stuck with how to tackle this... I guess that the changes in the columns are not being recorded anywhere so the status value for said column remains unchanged.

Could someone point me towards the right direction. I know I'm missing a few steps...

Thanks!

I think what you would want to do in the color field is use the same logic as you do for the status column but use "Green":"Red" at the end of it in place of "OK":"Review"

Uncheck "Assign colors automatically and you will see the Color field become available:

Screenshot 2025-03-27 at 1.39.36 PM

1 Like

Hi @gia,

Thanks for reaching out! Did you sort this out already? If not, here are some more questions/notes:

I'm not sure what this means. Are fee and proposed fee values editable? If so, currentSourceRow will only track saved column values - not any pending edits.

Does it always say "Review"? currentSourceRow only has access to values from the data source - not any custom column values. That might be part of the issue if it doesn't have access to the proposed fee value. If you are running into this issue where currentSourceRow doesn't have access to the proposed values, my next question would be what is the column type. Is it using the status indicator? If so, you get access to currentRow, and that should help to solve this issue. If it isn't a stats indicator, such as the tag column type, it may be worth adding the proposed values to the original table data source instead of using a custom column - happy to chat more about this if you'd like!

I agree with Scott as far as the color logic. You shouldn't need a variable. Rather, you can copy + paste the same logic ({{ currentSourceRow.fee_initial_value === currentSourceRow.proposedFeeValue ? "OK" : "Review" }}), but switch it to colors:
{{ currentSourceRow.fee_initial_value === currentSourceRow.proposedFeeValue ? "green" : "red" }}

1 Like

Hi @Tess @ScottR
Thanks so much for your assistance and solution, i put in the logic and it works beautifully now!

1 Like

Awesome - glad to hear!