Conditional Formatting on a Field that is on many layout...is there a better way?

I have a project where there is Conditional Formatting on a Layout_Field (named "Status") that is on approximately 30 Layouts.

The Conditional Formatting is based on the possible values in the field. The business has changed such that one value is NOT valid going forward and another value is now valid.

I could update the Conditional Formatting on 30 Layout_Fields...or...I could replace Conditional Formatting with a way that is 30x as DRY (Don't Repeat Yourself) and has other advantages (see below).

Please note that the notes and screen shots below are representative of the issue, and are based on code in my test system, not the customer project.

[1] Add a field named Status_Color_sCR, that makes use of a Custom Function...

png1x1 ( hex_string )

Place the Status_Color_sCR Field underneath Status Field and turn off the Fill on the Status Field.
I like to size Status_Color_sCR larger than Status Field so that color shows even when you are clicked into the Status Field (an advantage).

[2] Add a Field > Auto-Enter calculation to the "Status" Field.

// Self by itself seems to remove text formatting.
// make sure to remove text formatting elsewhere, as needed.

The [2] techniques above let me replicate all of the Conditional Formatting options except Icon Color, which is not part of a Field and are therefore a challenge for a different use case.

Lightly tested so far.
Not using WebDirect on this project.
Have fun!

1 Like

// this might be better
Case (
Self = "On Hold" ; TextStyleAdd ( Self ; Strikethrough ) ;
TextFormatRemove ( Self )
)

I actually use virtually the same container technique to allow users to select a primary color from a number of colors.
The text above such a colored container has a single conditional formatting that checks the brightness of the color and changes the text from black to white if necessary.

I get icons for buttons from an icon font. This allows me to control the icon color as well.

here is another technique: Dynamic background colour. This method can be implemented entirely within a single field, eliminating the need for conditional formatting.

  1. Create a calculated two-line text value
TextColor ( "status" ; RGB ( x ; x ; x ) )  &ΒΆ&
TextColor ( "β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ" ; RGB ( x ; x ; x ) )
  1. Use a custom function to control the color dynamically based on your logic

  2. On the layout, set the line height of the field to a small value (e.g. 0.2) so that the two lines overlap, creating the appearance of a colored background behind the text.

1 Like