[rt-users] Merging Tickets

rmp dmd rmp.dmd1229 at gmail.com
Fri Aug 7 16:21:39 EDT 2009


Hi,

I'm working on a scrip that will grab the subject of a new ticket and
compare it with existing ticket. If a match is found, the scrip will merge
the ticket. I have the script below.

I have additional requirement where I'll ignore preceeding characters and
merge if the next characters matched.

An example, this tickets should merge:

existing ticket: "Subject 1"
new ticket: "RE: Subject 1"

this example should merge also

existing ticket: "Subject A"
new ticket: "Fw: Subject A"

this example, should not merge:

 existing ticket: "Subject 2GO"
 new ticket: "Subject Any"

Thanks in advanced!


my $problem_desc = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader('Subject');
$problem_desc = $subject
$RT::Logger->debug("This is the subject to match: $problem_desc");
# look for subject on existing tickets
my $search = RT::Tickets->new($RT::SystemUser);
$search->LimitQueue(VALUE => 'IT');
$search->LimitStatus(VALUE => 'new', OPERATOR => '=', ENTRYAGGREGATOR =>
'or');
$search->LimitStatus(VALUE => 'open', OPERATOR => '=');
if ($search->Count == 0) { return 1; }
my $id = undef;
my $same_desc = undef;
while (my $ticket = $search->Next) {
    # Ignore this ticket that opened this transaction
    next if $self->TicketObj->Id == $ticket->Id;
    $ticket->Subject = $same_desc
    if ($same_desc eq $problem_desc){
       # Found the same subject
       $RT::Logger->debug("SAME $same_desc and $problem_desc");
       $id = $ticket->Id;
       $RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into
$id because of OA number match.");
       $self->TicketObj->MergeInto($id);
    }
}

$id || return 1;
1;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090807/f611f710/attachment.htm>


More information about the rt-users mailing list