Error trying to change the style of a field

Hello,

looking for a way to style a field depended on what value is in database (0 =red background / 1 = green background).

Or could I prefix the value with a green / red square, depending on the vale?

I tried:

OnLoadRecord:
sc_field_style({my_field}, ‘#33FF99’, ‘15px’, ‘#000000’, ‘Arial, sans-serif’, ‘bold’);

Fatal error: Uncaught Error: Call to undefined function sc_field_style() in C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\charge_tracker\form_charge\form_charge_apl.php:3705 Stack trace: #0 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\charge_tracker\form_charge\form_charge_apl.php(5505): form_charge_apl->nm_proc_onload_record(1) #1 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\charge_tracker\form_charge\form_charge_apl.php(1539): form_charge_apl->nm_select_banco() #2 C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\charge_tracker\form_charge\index.php(2032): form_charge_apl->controle() #3 {main} thrown in C:\Program Files\NetMake\v9\wwwroot\scriptcase\app\charge_tracker\form_charge\form_charge_apl.php on line 3705

Hi, Poltergeist.

sc_field_style macro is only available in the OnRecord event for GRIDS. From the name of your app I conclude you’re trying it in a FORM app.

But don’t panic. Here’s an example you could modifiy for your own purposes:

You could set visual attributes for form fields using a simple javascript function. Say you want to change color for a field:

  1. In the Programming section, create a Javascript method called jsSetColor and create two parameters, name them “color” and “field” (you could add parameteres to the function using the f(x) icon on top the editor).

  2. In the OnLoadRecord event, you could decide what color to apply and then call your function this way:

$field=<your field name>;
$color=‘some color name like black or green’;
sc_ajax_javascript(‘jsSetColor’,array($field,$color ));

And that’s it.

You could create similar functions to set background color, font, size, etc.; or you could create a single function with a set of parameters for each attribute.

Hope this helps.

Hello,

How can I do the same, but in total fields of a Group By?

I’ve tried using macros sc_field_style and sc_field_color, but no success!
They work perfect for normal fields, but I can’t change the style of totals according to their values.

Thanks in advance!