Change Background color in grid cell

Hi,

I am having a nightmare trying to get the background colour of a grid cell to change. I have this code in the onrecord event: -

$Color = {Progress_Colour};
if (!is_null($Color))
{
sc_field_style({Progress_Status}, $Color,’’);

}

The color is stored in another field on the table as the colors are variable . The above simply does not work. I know the color is correct. If I hard code the color to #FF0000 in the code it works. I know that indicates that maybe the color variable is’nt picking up anything but it is because I display it in the grid

What’s frustrating is that I have used the exact same in another grid and it works: -

$color_var = {EXP_Colour}; // Green
sc_field_style({EXP_Colour}, $Color_var, ‘’);

You need to use the color directly or with a global variable []

Ok, so the Global Variable suggestion actually doesn’t make a difference.

For context, I have a Priority table that contains a list of Priority Codes, Descriptions and associated colour. When I display that table in a grid I successfully change the background colour of the description field using: -

$color_var = {EXP_Colour}; // Green
sc_field_style({EXP_Colour}, $Color_var, ‘’);

I then have an Orders table that contains a Priority Field that effectively links back to the Priority table. What I wanted was when displaying the Orders Grid it fetched the Priority Colour from the priority table and then changed the background colour to the colour associated with the Priority Code. What I did, thinking it would be more efficient, was to change the SQL of the Orders Table and do a join against the Priority Table and include the colour in each row. The query works, the associated color value is included in every Orders row. But, using it in the same way as the code above simply does not work!!!

I don’t know why it doesn’t but it does not. So, I eventually reverted to the base SQL without a join and then in the OnRecord event of the Orders table did an sc_lookup on the Priority table to get the colour. Then stored that in a variable and used the same code as above - AND THAT WORKED!!!

Is there something peculiar about doing joins in your SQL that affects the code because that is all I can think of?