I would like to color a box red if another field is not empty. What would that formula look like?

  • 0
  • 1
  • Question
  • Updated 4 years ago
  • Answered
Photo of Tasha

Tasha

  • 0 Points

Posted 4 years ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
You have to distinguish between (1) coloring the font of a displayed field value from (2) coloring the background of the cell within which a field value is displayed. The first you can do with a conventional QuickBase formula. The following formulas (untested!) are when [OtherField] is a non-text field or a text field respectively:

If(IsNull([OtherField]),
  "<span style='color:red;'>" & ToText([Field]) & "</span>",
  "<span>" & ToText([Field]) & "</span>",
)

If(Len([OtherField]) = 0,
  "<span style='color:red;'>" & toText([Field]) & "</span>",
  "<span>" & ToText([Field]) & "</span>"
)

In both cases the formula field itself is a a text field with some HTML allowed set. Note there are three fields involved: (1) the field you are testing on [OtherFiled], (2) the field [Field] whose value you want to display potentially with a lot of red paint, and (3) the formula field above [What Ever You Named The Formula Field].

If your [Field] field is Numeric the above formulas will incorrectly justify to the left instead of the right.

if you want correct justification or if you want to color the background of the cell to be colorized you have to use the image onload technique as you have to set CSS properties on the <td> which contains displays the result.

I did not test these formulas so try it yourself and report back.
Photo of Tasha

Tasha

  • 0 Points
What if I want to verify no text in multiple fields?  How do I handle an OR operator?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 30,224 Points 20k badge 2x thumb
>What if I want to verify no text in multiple fields?  How do I handle an OR operator?

Just combine all the relevant criteria with an "and" operators like this:

If( IsNull([OtherField1]) and Len([OtherField2]) and IsNull([OtherField3]), Len([OtherField4]) = 0,
...
)