sc_field_style macro does not accept variable

I have a problem that the sc_field_style macro does not accept variable:

I use this in the OnRecord event on Grid app:

This works, but set all records to the specified colour, as expected:

sc_field_style({task_status}, '#ff0a0a' );

This does not work:

With single quotes:

$get_col = "SELECT colour_code from tbl_task_status where ID = {task_status}";
sc_lookup(rs_col, $get_col);
$bg_col= "'" .{rs_col[0][0]}."'"; // add single quotes
echo $bg_col;   //this returns the correct colour code
sc_field_style({task_status},$bg_col);

Without single quotes:

$get_col = "SELECT colour_code from tbl_task_status where ID = {task_status}";
sc_lookup(rs_col, $get_col);
$bg_col= {rs_col[0][0]}; // add single quotes
echo $bg_col;   //this returns the correct colour code
sc_field_style({task_status},$bg_col);

any idea how I could change the bg color on individual rows within the grid, based on the value of the field?

Hello,

Issue reported to our bugs team.

regards,
Bernhard Bernsmann

Solution

[QUOTE=symanix;14576]I have a problem that the sc_field_style macro does not accept variable:

I use this in the OnRecord event on Grid app:

This works, but set all records to the specified colour, as expected:

sc_field_style({task_status}, '#ff0a0a' );

This does not work:

With single quotes:

$get_col = "SELECT colour_code from tbl_task_status where ID = {task_status}";
sc_lookup(rs_col, $get_col);
$bg_col= "'" .{rs_col[0][0]}."'"; // add single quotes
echo $bg_col;   //this returns the correct colour code
sc_field_style({task_status},$bg_col);

Without single quotes:

$get_col = "SELECT colour_code from tbl_task_status where ID = {task_status}";
sc_lookup(rs_col, $get_col);
$bg_col= {rs_col[0][0]}; // add single quotes
echo $bg_col;   //this returns the correct colour code
sc_field_style({task_status},$bg_col);

any idea how I could change the bg color on individual rows within the grid, based on the value of the field?[/QUOTE]

Same problem, but try this, works for me:

$get_col = "SELECT colour_code from tbl_task_status where ID = {task_status}";
sc_lookup(rs_col, $get_col);
[bg_col]= {rs_col[0][0]}; // add single quotes
echo [bg_col];   //this returns the correct colour code
sc_field_style({task_status},[bg_col]);

Use Global varible. :stuck_out_tongue:

I am still seeing this same bug in SC version 8.00.0045.

Specifically, the macro sc_field_style will not accept the second parameter (it is the background color) as a {field} or $local variable. It will accept it as just putting in a quoted hex code like ‘#a12a12’ OR even as a [global] value.

So angelIrad’s work around still works, but this should be fixed so that a field value or local variable works too.

Just curiousity.
var_dump of var results to ‘#ff0a0a’ or ‘ff0a0a’?

In V9, this doesn’t work, even with a global variable.