Colorized List Formula

  • 0
  • 1
  • Question
  • Updated 2 years ago
  • Answered
I currently have a text formula that creates a list that looks like this:
List("\n",ToText( [Field 1])&" "&"Width",
ToText([Field 2])&" "&"Length",
ToText([Field 3])&" "&"Depth")

I want this list to be colorized so i created a formula like so:
"<span style=\"color:red;font-weight:bold;\">"&  [Colored List]&"</span>"

But when It displays it doesn't display as a list, it simply displays everything in one line.

What am i doing wrong? Thank you.
Photo of The Cobra

The Cobra

  • 84 Points 75 badge 2x thumb

Posted 2 years ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,698 Points 20k badge 2x thumb
I believe you need to 'style' each individual item WITHIN the list function.

however, I'm sure you will have to style things differently in total to get that affect.
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb

You will need to embed your html into the list code:

List ("\n","<span style='color:red;font-weight:bold;'>"ToText([Field 2])&"</span>"...


Photo of The Cobra

The Cobra

  • 84 Points 75 badge 2x thumb
Thank you. I tried it and it still doesn't list the items. Displays a single line. What could i be doing wrong?

List("\n","<span style=\"color:red;font-weight:bold;\">"&  ToText([Width])&"</span>",
"<span style=\"color:green;font-weight:bold;\">"&  ToText([Length])&"</span>",
"<span style=\"color:blue;font-weight:bold;\">"&  ToText([Depth])&"</span>")
Photo of Chris

Chris

  • 4,430 Points 4k badge 2x thumb
Let's try the "\n" at the end of each item. ...&"</span>"&"\n"&
(Edited)
Photo of Eric Mohlman

Eric Mohlman, Employee

  • 500 Points 500 badge 2x thumb
Official Response
The \n is a newline character, which works for regular formulas. Once you check the "allow some HTML" you now need to use the HTML new line character. I just tested in a dummy app to confirm this works:
"<span style=\"color:red;font-weight:bold;\">" & List("<br />",[Field1] & " Width",[Field2] & " Length",[Field3] & " Depth") & "</span>"
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
You are brilliant! The only modifications I needed to make were to add a closing parenthesis at the end of each line, and then I had to add the prefix 'ToText' for my numbers fields. As always, thank you so much!!!
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
One more question... On the Pass/Fail field (3rd one up from the bottom), I would like the text to appear in red if it’s ‘fail’, and green if it’s ‘pass’. Any suggestions?
No problem, just replace your one line with these two lines.  One of them will be null so it will not appear.

IF([Pass/Fail] = "Pass"
"Final Determination: " &"<span style=\"color:green;font-weight:bold;\">"&[Pass/Fail] & "</span>"),

IF([Pass/Fail] = "Fail"
"Final Determination: " &"<span style=\"color:red;font-weight:bold;\">"&[Pass/Fail] & "</span>"),
Photo of Eric Mohlman

Eric Mohlman, Employee

  • 500 Points 500 badge 2x thumb
It can also be simplified like this: "Final Determination: <span style=\"color:" & Case([Pass/Fail],"Pass","green","Fail","red") & ";font-weight:bold;\">" & [Pass/Fail] & "</span>"
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
Thank you both. It worked, Coach, but thank you for the additional option, Eric!