Skip to main content
Question

Multi User Select Field Colorization

  • March 21, 2017
  • 0 replies
  • 107 views

I am wondering if it is possible to colorize a multi-select field gracefully on a report. For example, I would like to assign each option in the field a color, but if two or more are selected I want all of their colors to show. 

So I have this list:

Jack (blue)
Carol (red)
Barbara (purple)
Janet (yellow)

I know that on my custom report I can colorize if there is only one selected. However, I am wondering if I, for instance, select both Jack and Barbara on this list can I have both blue and purple show? So on the report, it lists them both separated into different "bubbles". Can I colorize this report so each bubble shows the correct color? I have attached a couple screenshots for reference. The first is what the report looks like, the second is a mock up of what I am looking for. Thanks in advance!
This topic has been closed for replies.

  • Registered
  • March 21, 2017
What you will want to do is create a formula text field that converts those entries into colorized text.

It will need to evaluate each option that is there, and assign a color.

It will be a List function, with some if statements.

List(", ",
If(Contains([Name], "Jack"), "Blue Text", ""),
If(Contains([Name], "Carol"), "Red Text", ""),
If(Contains([Name], "Barbara"), "Purple Text", ""),
If(Contains([Name], "Janet"), "Yellow Text", "")
)

I'll need to circle back to this to make that text become colorized.  

Forum|alt.badge.img+12
  • Registered
  • March 21, 2017

  • Registered
  • March 21, 2017
instead of having "Blue Color" you can add this

"<div style=\"font-size: 10pt; color:white;background-color:blue; width:100%;  text-align:center; \">Jack</div>"

So this would need to be done for all combinations? So Jack would be blue, Carol would be red, and the combination of Jack and Carol would be a third color?

  • Registered
  • March 21, 2017

  • Registered
  • March 21, 2017
Correct (At least going this route),  If you have a ton of options there are a few other ways, but multi select fields are tricky.

Here is a more complete formula for your example

List(", ",
If(Contains([Name], "Jack"),
"<div style=\"font-size: 12pt; color:white;background-color:blue; width:100%;  text-align:center; \">Jack</div>", ""),
If(Contains([Name], "Carol"),
"<div style=\"font-size: 12pt; color:white;background-color:red; width:100%;  text-align:center; \">Carol</div>", ""),
If(Contains([Name], "Barbara"),
"<div style=\"font-size: 12pt; color:white;background-color:purple; width:100%;  text-align:center; \">Carol</div>", ""),
If(Contains([Name], "Janet"),
"<div style=\"font-size: 12pt; color:white;background-color:yellow; width:100%;  text-align:center; \">Carol</div>", "")
)

There is no way to run a loop in QuickBase formula.  Therefore, there is a lot of repeating syntax.  I built it out for 4 users.  This would need to be built out for 20 users total.  Also, users are hard coded which is going to be a pain to maintain over time.  Good Luck!


var text jackstyle = "background: purple; color: white; border-color: purple'>Jack";
var text janetstyle = "background: yellow; color: black; border-color: yellow'>Janet";
var text carolstyle = "background: red; color: white; border-color: red'>Carol";
var text barbarastyle = "background: blue; color: white; border-color: blue'>Barbara";

var text css = "display: inline-block; margin: 1px; background: white; max-width: 98%; "&
"text-overflow: ellipsis;word-wrap: break-word; background: red; border: 1px solid rgb(204, 213, 240);" &
"border-radius: 5px; padding: 2px; -moz-border-radius: 5px; -webkit-border-radius: 5px;";

var text usera = Part(ToText(
    ), 1, ";");
    var text userb = Part(ToText(
      ), 2, ";");
      var text userc = Part(ToText(
        ), 3, ";");
        var text userd = Part(ToText(
          ), 4, ";");

          var text useraf = If(
          Contains($usera, "jack")=true, $jackstyle,
          Contains($usera, "janet")=true, $janetstyle,
          Contains($usera, "carol")=true, $carolstyle,
          Contains($usera, "barbara")=true, $barbarastyle 
          );

          var text userbf = If(
          Contains($userb, "jack")=true, $jackstyle,
          Contains($userb, "janet")=true, $janetstyle,
          Contains($userb, "carol")=true, $carolstyle,
          Contains($userb, "barbara")=true, $barbarastyle
          );

          var text usercf = If(
          Contains($userc, "jack")=true, $jackstyle,
          Contains($userc, "janet")=true, $janetstyle,
          Contains($userc, "carol")=true, $carolstyle,
          Contains($userc, "barbara")=true, $barbarastyle
          );

          var text userdf = If(
          Contains($userd, "jack")=true, $jackstyle,
          Contains($userd, "janet")=true, $janetstyle,
          Contains($userd, "carol")=true, $carolstyle,
          Contains($userd, "barbara")=true, $barbarastyle
          );

          "<span style='" & $css &
          List("</span><span style='" & $css,
          $useraf,
          $userbf,
          $usercf,
          $userdf,
          ""
          )&
          "</span>

  • Registered
  • March 22, 2017
>Also, users are hard coded which is going to be a pain to maintain over time.  Good Luck!

You could just write a short off-line JavaScript function that took an array of user names and styles and spit out the QuickBase formula as text. Whatever repeating pattern is in the QuickBase formula can easily be iterated over in script.

  • Registered
  • March 22, 2017
UPDATE: I made a simple  change to detect dynamic filters through the hashchange event:

https://haversineconsulting.quickbase.com/db/bmm3bpupr?a=td

Pastie Database
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=563

No need to use Mutation Observers with this change.

I also unchecked the Searchable property of the [-] field so remnants of this field would not display in the dynamic filter panel:

     Include this field when searching/filtering this table

To be honest I can't believe QuickBase implemented this dynbamic fitler option through using the URL hash - the change state should have been persisted in local storage.

I may not understand everything you are saying here, but it certainly works like a charm! Thanks so much!