[rt-users] How to join two RT tables in perl?

Morten Guldager morten.guldager at gmail.com
Mon May 5 09:09:12 EDT 2008


'Aloha!

In my standalone program I would like to do a join on the tables
Transactions and Users in order to add Users.Name to my print
out. (and not just the user number)

But I somehow lost track while trying to figure out how it is done
in the RT code itself.

Below is a boiled down demo program which fails in the second
last line, which is somehow expected.

  RT::Transaction::Name Unimplemented in main. (./Join-demo-2 line 31)

Perhaps somebody can help me in the right direction.

-- 
/Morten %-)

#!/usr/bin/perl

package RT;
our $DatabaseType     = 'mysql';
our $DatabaseUser     = 'rtuser';
our $DatabasePassword = 'wibble';
our $DatabaseName     = 'rtdb';

package main;
use strict;
use warnings;
use lib '/usr/share/request-tracker3.6/lib';
use RT;
use RT::Transactions;

RT::Init();
my $CurrentUser = RT::CurrentUser->new('cust-12345');

my $t = new RT::Transactions($CurrentUser);
$t->LimitToTicket(1);

my $u = $t->NewAlias('Users');
$t->Join(ALIAS1 => 'main',
         FIELD1 => 'Creator',
         ALIAS2 => $u,
         FIELD2 => 'id');

while (my $row = $t->Next)
{
  printf "id:%s, CreatorId:%s, Name:%s\n", $row->id, $row->Creator,
$row->Name;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20080505/504ce959/attachment.html>


More information about the rt-users mailing list