[rt-users] Merge tickets using Perl API?
Nathan Cutler
presnypreklad at gmail.com
Sun Jul 7 05:56:12 EDT 2013
Greetings, RT enthusiasts!
I am trying to merge two pre-existing tickets by a stand-alone Perl script.
Here's the full script:
<CODE>
#!/usr/bin/perl
use strict;
use warnings;
use RT;
use RT::Ticket;
my $CurrentUser;
BEGIN {
# make STDERR unbuffered
binmode(STDERR, ":unix")
|| die "can't binmode STDOUT to :unix: $!";
print STDERR "Initializing RT...";
RT->LoadConfig;
RT->Init;
# Become RT System User
$CurrentUser = RT::CurrentUser->new;
$CurrentUser->Load(RT->SystemUser);
die "Could not become RT System User" unless $CurrentUser;
print STDERR "Done.\n";
}
my $TicketA_id = 33842; #Ticket A
my $TicketB_id = 34497; #Ticket B
my $TicketA_obj = new RT::Ticket(RT->SystemUser);
$TicketA_obj->Load($TicketA_id);
my ($val, $msg) = $TicketA_obj->AddLink(
Type => 'MergedInto',
Target => $TicketB_id,
);
print "RT::Ticket::AddLink returned val '$val' and msg '$msg'\n";
</CODE>
And here's the output:
Initializing RT...Done.
RT::Ticket::AddLink returned val '6' and msg 'Ticket 33842 merged into
Ticket 34497.'
In the web UI, I see the following transactions are created:
In ticket 33842:
The RT System itself - Merged into ticket #34497
In ticket 34497:
The RT System itself - Merged into ticket #33842
Needless to say, the tickets are not merged properly - they continue
to be displayed separately.
Advice, pointers how to do this properly?
Thanks in advance!
Nathan
More information about the rt-users
mailing list