[rt-users] Merge tickets using Perl API?

Kevin Falcone falcone at bestpractical.com
Mon Jul 8 10:51:32 EDT 2013


On Sun, Jul 07, 2013 at 11:56:12AM +0200, Nathan Cutler wrote:
> Greetings, RT enthusiasts!
> 
> I am trying to merge two pre-existing tickets by a stand-alone Perl script.
> 
> Here's the full script:

You want to use
http://bestpractical.com/rt/docs/latest/RT/Ticket.html#MergeInto

Creating the link is only a very small part of the process.

-kevin

> <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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 235 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130708/38373ac2/attachment.sig>


More information about the rt-users mailing list