This is a public Forum  publicRSS

Forum post

    Script to change color of one field based on condition of...
    Forum post posted June 14, 2010 by Jebber, last edited February 9, 2012 
    2703 Views, 8 Comments
    Script to change color of one field based on condition of another field

    I am looking for a script / method of changing the color of a field based on the value in another field. How do you do that?


    Example; IF Field:customer = AMAT, then Field:action = the fill color red


    I would really appreciate the help here.



    • Steve Wright

      Right click on the field you wish to format, then choose Conditional Formatting.


      You can then set up formula's such as  Field::Customer = "AMAT"  

      Then specify the colour options etc if that is true.


      If you wanted to apply conditional formatting using the same calculations to other fields etc, select them all first, then right click and choose conditional formatting.  This will apply the formatting to everything selected.


    • Jebber

      Thanks for the assistance.


      But I think I have the format wrong. What is the proper format to put in the Formula Is area?


      I keep getting a return saying that it cannot find my field.


      The condition field is "Top 30 Customer Type"

      The resulting field that I would like to change the color in is "Color Block"



    • Steve Wright

      You would apply the conditional formatting to the "Color Block" field


      Forumula is :


      Top 30 Customer Type = "AMAT"


      You may need to prefix the field name with the table name, but if you click specify you can select the field from the available list and it will format it correctly for you  i.e


      CustomerTypes::Top 30 Customer Type = "AMAT"



    • luis

      Is there a way to change the fill color without using conditional formatting? I'd like to do this because conditional formatting is not available in instant web publishing.

    • PhilModJunk

      Create two calculation fields: If ( conditionalExpression ; FieldName ; "" )

      Format each with a different color, stack them on top of each other with a transparent fill color and use conditional expressions that will always leave one field blank and the other displaying data. (That's how we did this in older versions without conditional formatting. Don't see why it wouldn't work with IWP.)

    • luis

      Thanks Phil

      Unless I am missing something, the transparent fill pattern implies no fill color, so the approach you suggest does not seem to work for my purposes. However, it does allow me to use indentation rather than background color to convey the difference between my data, which seems good enough :)

      thanks again,

    • PhilModJunk

      Good point as I was thinking in terms of changing the text color rather than the fill color. To do that you can set up a calculation that returns a container type. It can return the contents of a container field that has a red rectangle in it to show a red "fill color" and it can return the contents of a container field with a blue rectangle to show a blue "fill color"...

      Now put this field behind your transparent data field to show a "fill color" change.

    • Armando Pedroza

      I was able to do this in my printing shop database without any difficulty, here's how:

      1. the formatted color of the field "Printing Machine" is set to white (my default)

      2. I want this to change to black when the "Current Status" is updated to 05-FINAL LAYOUT and remain black even if it is updated to the next processses.

      3. now go to layout and right click on the field you want to change the color or to set the condition.

          in my case, its like this:       FLEXI DB::CURRENT STATUS  ≥  "05 - FINAL LAYOUT"

      4. then set the text format to black.