Simplicty and flexibility!


SetColor - how to make it fire NOW not wait until you hit save.


Started by Simon B
Search
You will need to Sign In to be able to add or comment on the forum!

SetColor - how to make it fire NOW not wait until you hit save.

I have a control field with ghe following derivation:

concat(
SetColor("hist_d1","-1",rgb1,"-1"),
SetColor("hist_s1","-1",rgb1,"-1"),
SetColor("hist_t1","-1",rgb1,"-1"),
SetColor("hist_idn1","-1",rgb1,"-1"),
SetState("histc01",0)
)

This sets the colour of 4 fields to the value stored in rgb1 which is a virtrual derived lookup.

This control field is top left corner, tab order 1.

Does anyone know how to make SetColor actully SET COLOUR without having to hit save first to make it fire?

I want SetColor to work straight away, not wait untilAFTER  I've saved an order to highlight important fields in colours.  The whole point is to highlight fiedls in colour BEFORE someone orders.

Anyone had any luck with this?  I had to revert back to olde faithful OML and rewrite it back as it does colour changing straight away, but I'm still looking for the holy grail as OML is being replaced by this which runs after the effect.  Thank you :)


Written by Simon B 15/06/15 at 14:02:05 Dataease [{8}]FIVE

Re:SetColor - how to make it fire NOW not wait until you hit save.

1. Is the field with the derivation concat(SetColor("hist_d1","-1",rgb1,"-1"),SetColor("hist_s1","-1",rgb1,"-1"),SetColor("hist_t1","-1",rgb1,"-1"),SetColor("hist_idn1","-1",rgb1,"-1"),SetState("histc01",0))

a virtual field. If it is not virtual it will not be fired until it is saved or touched.

2. Is the field higher up or lower down than the field rgb1? If it is higher up it will be fired before rgb1.

3. You can have a dependent field recompute when the field it depends on is changed, simply add if (rgb1 not=blank, concat(

SetColor("hist_d1","-1",rgb1,"-1"),
SetColor("hist_s1","-1",rgb1,"-1"),
SetColor("hist_t1","-1",rgb1,"-1"),
SetColor("hist_idn1","-1",rgb1,"-1"),
SetState("histc01",0)
),0)

However.....

You are doing it very awkward, why don't you 

1. use SetStyle() instead of SetColor.
2. As you want it to change when something change, why don't you do the if directly? if (this or that, SetStyle("hist_d1","OnStyle")+SetStyle("hist_s1","OnStyle) etc.

3. Use a LabelExecDQL or a MemoExecDQL or simply a ExecDQL and use a case switch if you like.


To be honest, I have never had the problem with triggering but you need to follow the basic rules to trigger derivations in DFW.


Written by DataEase 16/06/15 at 09:16:56 Dataease [{8}]FIVE

Re:Re:SetColor - how to make it fire NOW not wait until you hit save.

1. Yes, the field with the derivation mentioned is a virtual field.

2. The field is higher up than field rgb1 (also a virtual derived field)  It is the 1st field top left corner to ensure it is the first field to fire.

I've followed all basic rules to trigger derivations in DFW, all the ones I can find documented anyway.

I'm not sure how setstyle is any less awkward, it seems to have pretty much the same information so no less scripting/coding/writing involved.

This is just for 1 history line. There are 14 lines of history on the order screen, this needs 14 control fields with setcolor, or 14 control fields with setstyle.  I can't even get 1 to change colour and fire first even when i've done all the above.


Written by Simon B 16/06/15 at 09:32:44 Dataease [{8}]FIVE

Re:Re:Re:SetColor - how to make it fire NOW not wait until you hit save.

control field lower than rgb tried, no difference.  Lookup entry data from an order screen, I have everything, supplier name, desciptions, prices, history, everythnig is on my screen, nothing is going to change, it just needs to look at whats been looked up and put into the fields and change filed colours to match the shown info.  Everything works before I hit save lol.


Written by Simon B 16/06/15 at 10:15:39 Dataease [{8}]FIVE

Re:Re:Re:SetColor - how to make it fire NOW not wait until you hit save.

Tried adding 

if (rgb1 not=blank

to the start

(with ,"" at the end not ,0 as it's a text field and wouldn't accept it)

colour changing of fields does not work until you save them. Once saved they show correct all the time, but until a record is saved setcolor etc is not fired and everything is grey.


Written by Simon B 16/06/15 at 10:24:04 Dataease [{8}]FIVE
DG3_ForumList