Can you help with this minor hack?

For better or worse, I’ve decided to hack the interface for RT and have
been playing with the ‘Home’ screen. All of the requests are from local
staff and I would like to include their name as an additional column in
the “25 highest priority tickets I own…” panel.

The closest I can get is by using

<%$Ticket->Requestors->EmailsAsString%>

to put in their email address. However, all these requestors will be
RT users with a “real name” field, which is what I would actually like
to show instead of the email address.

I have dredged the code trying to work my way around the objects and
subroutines, but have got stuck.

What do I need to change the above code to, in order to display the Full
Name of the requestor?

Cheers,

Dave.
Dave Ewart
Dave.Ewart@cancer.org.uk
Computing Manager, Epidemiology Unit, Oxford
Cancer Research UK
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370

<%$Ticket->Requestors->EmailsAsString%>

At a rough guess, try:

% my $requestors = $Ticket->Requestors;
% while( my $this_requestor = $requestors->Next ){
% if( defined( $this_requestor->OwnerObj ) ){
<% $this_requestor->OwnerObj->RealName %>
% }
% }

Of course, <% $Ticket->Requestors->First->OwnerObj->RealName %> might not
work either. I need caffiene to get to sleep.

Regards,

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

<%$Ticket->Requestors->EmailsAsString%>

At a rough guess, try:

% my $requestors = $Ticket->Requestors;
% while( my $this_requestor = $requestors->Next ){
% if( defined( $this_requestor->OwnerObj ) ){
<% $this_requestor->OwnerObj->RealName %>
% }
% }

Of course, <% $Ticket->Requestors->First->OwnerObj->RealName %> might not
work either. I need caffiene to get to sleep.

Won’t this just display the realname of the $Ticket owner?

Hmm. No, after testing both, they do appear to return the realname of the
Requestor.

Why wouldn’t $Ticket->Requestors->First->OwnerObj->RealName return the
same thing as $Ticket->OwnerObj->RealName?

Is it because the former has no OwnerObj assigned to it, causing the
RT::Watcher->OwnerObj method to load the RT::User object for the first
watcher returned by First?

I’m so confused. :slight_smile:

Travis
Travis Campbell - Unix Systems Administrator = travis@beast.amd.com
5900 E. Ben White Blvd, Austin, TX 78741 = travis.campbell@amd.com
TEL: (512) 602-1888 PAG: (512) 604-0341 = webmaster@beast.amd.com
"Does anything work as expected?" Yes. An axe through the CPU.

At a rough guess, try:

% my $requestors = $Ticket->Requestors;
% while( my $this_requestor = $requestors->Next ){
% if( defined( $this_requestor->OwnerObj ) ){
<% $this_requestor->OwnerObj->RealName %>
% }
% }

Of course, <% $Ticket->Requestors->First->OwnerObj->RealName %> might not
work either. I need caffiene to get to sleep.

Won’t this just display the realname of the $Ticket owner?

urm, you’re wanting a complicated answer, and I need some sleep.

Hmm. No, after testing both, they do appear to return the realname of the
Requestor.

Why wouldn’t $Ticket->Requestors->First->OwnerObj->RealName return the
same thing as $Ticket->OwnerObj->RealName?

Is it because the former has no OwnerObj assigned to it, causing the
RT::Watcher->OwnerObj method to load the RT::User object for the first
watcher returned by First?

I’ll try to do a pretty schema. Note that this is applicable to 2.0.x, so
if you’re reading the archives in a year or so, this probably won’t help
you.

  Ticket (RT::Ticket)
      |   |
      |  Ticket->OwnerObj()
      |   |
      |   \--> Owner of Ticket (RT::User)
      |              |
      |              \-> RealName()
      |
   Ticket->Requestors()
  |
  \---> Requestors of Ticket (RT::Watchers with Type 'Requestor',)
                 |               (Scope 'Ticket' and Value Ticket->id)
                 |
            Ticket->Requestors->Next() (or First() )
                 |
             \-> Single Requestor (RT::Watcher)
                           |
                        ->OwnerObj()
                           |
                           \-> Owner of Requestor Object (RT::User)
                                     |
                                     \-> RealName()

In both cases, we’re querying the RealName() method of an RT::User object.
We’ve gotten there in different methods.

Ticket->OwnerObj->RealName displays the RealName column of the Owner of
the Ticket, by effectively issuing:

select Users.RealName \
From Users, Tickets \
where Tickets.Owner = Users.id \
and Tickets.id = 'this.ticket.number';

Ticket->Requestors->First->OwnerObj->RealName displays the RealName column
of the first ‘Requestor’ of the Ticket, by effectively issuing:

select Users.RealName \
from Users, Watchers \
where Watchers.Type = 'Requestor' \
and Watchers.Scope = 'Ticket' \
and Watchers.Value = 'this.ticket.number' \
and Watchers.Owner = Users.id ;

Its probably easier to understand as:

Ticket->Requestors() returns a list of Watcher objects which are
marked as 'Requestor's on this specific ticket.

->First() returns the first match found.  Calling ->Next()
repeatedly iterates through the list found.  First should always
return an object, Next will return undef once it gets to the end
of the list, so don't use Next() when you just want one, as you'll
shoot your foot off quite nicely.

->OwnerObj returns the RT::User whose id matches the value of the
Owner field of the Watcher object returned by First().

->RealName is obvious.

To answer your question (several pages up), they’re not the same object.
They’re the same object type, but markedly different paths to get there.

That explains ticket Owners and ticket Requestors. I’d appreciate it if
you could do a similar schema to describe human female behaviour (without
using rand()!) :wink:

                         Bruce Campbell                            RIPE
               Systems/Network Engineer                             NCC
             www.ripe.net - PGP562C8B1B                      Operations

<%$Ticket->Requestors->EmailsAsString%>

At a rough guess, try:

% my $requestors = $Ticket->Requestors;
% while( my $this_requestor = $requestors->Next ){
% if( defined( $this_requestor->OwnerObj ) ){
<% $this_requestor->OwnerObj->RealName %>
% }
% }

Of course, <% $Ticket->Requestors->First->OwnerObj->RealName %> might not
work either. I need caffiene to get to sleep.

That does the trick, Bruce, many thanks. And thanks for the schema
elsewhere is this thread - that might help my understanding of the
source a little!

Cheers,

Dave.
Dave Ewart
Dave.Ewart@cancer.org.uk
Computing Manager, Epidemiology Unit, Oxford
Cancer Research UK
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370