Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

SetFieldStyle Rule Issue

Highlighted
Deepak Bhattad
Regular Collector

SetFieldStyle Rule Issue

Hi,

 

I have been trying to set the field background of a date field (B) based on another date field (A).

 

If A is earlier than B then set the color of B to red.

 

I could successfully achieve this by adding the classfile in the css file.

 

However now I would like to change the color of the field to the color of the request form if the user changes the date value (B) earlier than A.

 

I tried using white background and this works but when again I change the date field B to later than A then the red backgorund does not show up and the field is white in color.

 

I believe the white color is overriding the red color or so but not sure.

 

Any help in this regard is greatly appreciated.

 

Regards,

Deepak

12 REPLIES
kndlny
Regular Collector

Re: SetFieldStyle Rule Issue

Hi Deepak,

Suppose you have added a class file name redBackground and have a field change rule such as:

 

IF A < B ; setFieldStyle("redBackground")

 

and you need another field change rule IF A > B in order to change the background color to default.

 

To do that, simply use setFieldStyle("").

 

Deepak Bhattad
Regular Collector

Re: SetFieldStyle Rule Issue

Thanks for the inputs.

 

This however does not solve the problem.

 

The field changes to red but does not change to default on the A >B.

 

I have attached the snapshot of the rule for your reference. Here the field "Actual Final Analysis Plan (SAP)" is the field B which is changed.

 

 

kndlny
Regular Collector

Re: SetFieldStyle Rule Issue

Hi Deepak,

 

Can you try it with only a single dependency in your rule, such as "Actual Final Analysis Plan (SAP)" is null.

 

You may need to define two different rules for each dependency, if this works.

Deepak Bhattad
Regular Collector

Re: SetFieldStyle Rule Issue

Hi,

 

Still no luck.

 

I defined two rules - one for null and one for > B but the rule still does not seem to trigger.

 

Not sure where the issue is?

 

Regards

Mohit_Agrawal
Frequent Visitor

Re: SetFieldStyle Rule Issue

Hi..

 

You need to create 4 rules for this UI logic.

 

1) "Apply on field Change" 

IF A < B ; setFieldStyle("redBackground")

 

2) "Apply on field Change" 

IF A !< B ; setFieldStyle("")  ( Use A is not less than B, rather than A>B)

 

3) "Apply on page load" 

IF A < B ; setFieldStyle("redBackground")

 

4)  "Apply on page load"  

IF A !< B ; setFieldStyle("")

 

 

Thanks!!
--Mohit Agrawal
-- Remember to give Kudos, if this solves your query!!

Deepak Bhattad
Regular Collector

Re: SetFieldStyle Rule Issue

It looks like the first time the color applied to the field remains and then it does not overwrite it.

 

I tried white color on A<B (remember A > B is red) and then i changed the field A > B and red does not seem to apply.

 

For some reason the color code is not overwritten.

 

Any thoughts?

Jim Esler
Honored Contributor

Re: SetFieldStyle Rule Issue

All conditions listed in the Dependencies section of a rule need to be met in order for the rule to be executed. In your screenshot, the field name 'Actual Final Analysis Plan (SAP):' is listed twice, once for null and once for before the value of another field. If the field is null, it probably meets both conditions. If there is a value in the field, though, it is no longer null and the rule will not be executed.

Deepak Bhattad
Regular Collector

Re: SetFieldStyle Rule Issue

Hi Jim,

 

I would agree with your comments.

 

Hence I did try writing separate rules for null condition and less than condition but nothing seems to be working.

 

In the CSS stylesheets at the beginning I did use the "! important" criteria while defining the background styles and then changed it.

 

Do i need to restart the server by any chance to make the changes effective?

 

Regards,

Jim Esler
Honored Contributor

Re: SetFieldStyle Rule Issue

It would not be necessary to restart the server to have rule changes take effect. You should refresh the browser window, though. My only other suggestion is to try a test with only the one rule enabled just to eliminate the possibility that another rule is undoing this one.

KeanChen
Super Collector

Re: SetFieldStyle Rule Issue

I was have the same problem, My solution is:

1.- Create separated rules
2.- And Refresh the cache browser
3.- Or create a *.bat procedure that execute kRunCacheManager.sh -a every time

I hope help.

Best Regards.
Jim Esler
Honored Contributor

Re: SetFieldStyle Rule Issue

Keep in mind that the caches are maintained by the application to improve performance. Every time a cache is cleared the entries have to be pulled from the database instead of the cache. In order to minimize the impact on performance you should only clear the caches related to entities that you change manually with direct database queries. An example would be when we change user information in user registration entries, we clear only the Users cache. Any change that you make through a PPM interface should not require clearing any cache as the cache entries should be updated automatically in all nodes. If it is not, it is a defect.

Deepak Bhattad
Regular Collector

Re: SetFieldStyle Rule Issue

Not sure how do refresh the cache based on a rule / java script.

 

Do we really need to refresh the cache on an interface action?

//Add this to "OnDomLoad" event