perlrt

Request Tracker - Changing Queue Color


I'd like to change the ticket table in RT to have a custom "Queue" color. I am using this guide as a reference:

http://requesttracker.wikia.com/wiki/ShowStatusInColor

... which works. The following code in a Callback will update all "Priority" fields to be red:

<%INIT>
      # Set the priority color.
      sub PriorityInColor {
        my $Ticket = shift;
        my $priority = $Ticket->Priority;
        my $colors = "#FF0000";
        $priority = "<div style=\"color: $colors;\">$priority</div>";
        return \"<b>$priority</b>";
      }

      $COLUMN_MAP->{Priority}->{value} = \&PriorityInColor;
</%INIT>

<%ARGS>
    $COLUMN_MAP => undef
</%ARGS>

Looks like this:

Priority shows up red

This also holds true for most other fields except the Queue. When applied to Queue, it has no result at all:

<%INIT>
      # Set the queue color.
      sub QueueInColor {
        my $Ticket = shift;
        my $queue = $Ticket->Queue;
        my $colors = "#FF0000";
        $queue = "<div style=\"color: $colors;\">$queue</div>";
        return \"<b>$queue</b>";
      }
      $COLUMN_MAP->{Queue}->{value} = \&QueueInColor;
</%INIT>

<%ARGS>
    $COLUMN_MAP => undef
</%ARGS>

I feel like I'm missing some additional arguments for Queue, but I can't for the life of me make sense of the structure if that's the case. Thanks in advance for any help!


Solution

  • After some more trial and error, I found the issue! Queue references the internal number of the queues, QueueName references the actual string in the table. In addition, you have to call the name via "QueueObj" to get the Name attribute. Here's the working block:

    <%INIT>
          # Set the queue color.
          sub QueueInColor {
            my $Ticket = shift;
            my $queue = $Ticket->QueueObj->Name;
            my $colors = "#FF0000";
            $queue = "<div style=\"color: $colors;\">$queue</div>";
            return \"<b>$queue</b>";
          }
          $COLUMN_MAP->{QueueName}->{value} = \&QueueInColor;
    </%INIT>
    
    <%ARGS>
            $COLUMN_MAP => undef
    </%ARGS>