I think there is a bug in sc_field_style macro:

[INDENT]sc_field_style({field1}, {filed2});[/INDENT]
[INDENT]sc_field_style({field1}, $variable1);[/INDENT]

don’t works…

have you tried:

sc_field_style(field1, {filed2});
sc_field_style(field1, $variable1);



Issue reported to our bugs team.

Bernhard Bernsmann


As I initially thought sc_field_style does not accept variables as parameter.

Bernhard Bernsmann

Hello, I’m pretty new to the forum and to scriptcase, and I know it’s pretty old thread/topic.
However in my attempts to have sc_field_style to work with dynamic parameters, I have found a way to do that I wanted to share ( and sorry if there’s better options )
I’m using Scriptcase This results from study of the generated PHP code for my application.

First, I have a lookup function created to retrieve my parameters :

function getColorFromCode ($Code)

if (!empty($res)) {
$foreColor = $res [0][2];
$backColor = $res [0][3];
$fontSize = $res [0][4];
} else {
$foreColor = "#000000";
$backColor = "#FFFFFF";
$fontSize = "15px";

$style = "background-color:".$backColor.";font-size:".$fontSize.";color:".$foreColor.";";
return $style;

That creates and returns the style entries I’m looking for.
In the grid onRecord events, I have the following :

1. $st = getColorFromCode($dt);
2. sc_field_style({DATE_RATIO},[backColor],[fontSize],[foreColor]);
3. $this->NM_field_style["date_ratio"]=$st;

Code details :

  1. retrieves my style string.
  2. the ‘not working’ call to the function is however required ( for all sorts of initialisations in Scriptcase )
  3. I’m simply overwritting the style elements for the field I’m looking for.

Hope it helps

Old thread (and not the only one about this), but a needed solution.
I have to search now for all my hardcoded color-changing events, and I hope your solution works! (no reason why it shouldn’t I guess)

It works on v9.2.
Previous solutions I had found (some of them in portuguese, from brazilian forum users, did not work, apparently because they were not using the “not working” call to the sc_field_style macro (your step 2)

One more tip for newbies like me though… the field name in NM_field_style, has to be in lowercase, and all dots or schema separators have to be replaced by underscores (eg: “clients.ClientName” has to be called as “clients_clientname”)