How to use conditional formatting in Scriptcase

Hi All,

I’m pretty new to Scriptcase. I made a nice Grid work.
Now I want to define a conditional formatting just like in Excel.

I have a duration of minutes type. I want to be able to paint the background of that row red when this time exceeds, for example, 5 minutes. How can I do this in a practical way?

Hello…
You can do in LoadRecord event, with sc_field_style…
Sample…

if ({Pla.Finalizado} == 1) {
	sc_field_style({Pla.DESCRIPCION}, '', '', '#00FF00' , '', '');
} else {
	sc_field_style({Pla.DESCRIPCION}, '', '', '#99FFFF' , '', '');
}

In this code, the colour of field “Pla.Descripción” is set according the value of flag Pla.Finalizado…

2 Likes

Thanks for your answer,

I want to paint as in the example below.

I used the code you gave, this way. But it had no effect. am i doing something wrong?

1 Like

You have to declare ALL fields in your condition, like this:

if({nm_status} == "Encerrado") 
{
	sc_field_style({cd_loja}, "#2fe2ff");
	sc_field_style({cd_pedido}, "#2fe2ff");
	sc_field_style({dt_emissao}, "#2fe2ff");
	sc_field_style({dt_encerramento}, "#2fe2ff");
	sc_field_style({total}, "#2fe2ff");
	sc_field_style({desconto}, "#2fe2ff");
	sc_field_style({total_final}, "#2fe2ff");
	sc_field_style({razao_social}, "#2fe2ff");
	sc_field_style({nm_status}, "#2fe2ff");
	sc_field_style({usuario_cad}, "#2fe2ff");
	sc_field_style({cd_vendedor}, "#2fe2ff");
} else if({nm_status} == "No Caixa")
{
	sc_field_style({cd_loja}, "#FFCC00");
	sc_field_style({cd_pedido}, "#FFCC00");
	sc_field_style({dt_emissao}, "#FFCC00");
	sc_field_style({dt_encerramento}, "#FFCC00");
	sc_field_style({total}, "#FFCC00");
	sc_field_style({desconto}, "#FFCC00");
	sc_field_style({total_final}, "#FFCC00");
	sc_field_style({razao_social}, "#FFCC00");
	sc_field_style({nm_status}, "#FFCC00");
	sc_field_style({usuario_cad}, "#FFCC00");
	sc_field_style({cd_vendedor}, "#FFCC00");
}

And put this in onRecord event.

1 Like

sc_field_style({My_Field}, “Background-Color”, “Size”, “Color”, “Family”, “Weight”)

Put the hexa color in “Background Color”…

1 Like

Gentlemen, thank you very much. It was exactly how I wanted it.

Another question came to my mind regarding this issue.

Is it possible to make flashing text in values less than 2 minutes?
they call it .blink. How can I make the text blinking in values as small as 2 minutes? Have you ever experienced this before?