Merging Tickets

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;

Dear All

Is there a way to prevent ticket merging when the tickets are not in the same queue?

Thank you

[cid:imagee92028.PNG@8ec91e59.4393fd59] [cid:imageb687a0.PNG@90c86cb5.4d8b7e62]
Thanos Constantopoulos
Escalation Engineer

[cid:image8ee56d.PNG@2a20f1ce.4a9f79c4]
tconstantopoulos@odysseyconsultants.commailto:tconstantopoulos@odysseyconsultants.com

[cid:image1a2fa5.PNG@01c97f45.44a1c38f]
Extension: # 144

[cid:image804318.PNG@5c0af0d6.4ebe7967]
1, Lefkos Anastasiades Street, 3rd Floor, 2012 Strovolos, Nicosia Tel.: +357 22463600

[cid:image4d63dd.PNG@807422b4.4daf808e]http://www.odysseyc.com/cloudservices/SIEM/

This e-mail contains proprietary information some or all of which may be legally privileged. It is for the intended recipient only. If an addressing or transmission error has misdirected this e-mail, please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print or rely on this e-mail. The content of this email may contain private views and opinions, which do not constitute formal disclosure or commitment unless specifically stated.

[cid:image49618f.PNG@b0007398.47906101]http://www.odysseyc.com [cid:image23ad1b.PNG@89d02a91.4ba9fd82] https://www.facebook.com/OdysseyCyberSecuriy [cid:imagebbd647.PNG@edc821b0.4e91b840] https://twitter.com/Odysseycybersec [cid:image77181d.PNG@8995fb7b.4fad1977] http://www.linkedin.com/company/odyssey-consultants
[cid:imageaf20dd.JPG@1e264a19.4581a552] [cid:imaged6a67c.JPG@e000386c.4786955d] [cid:imagea4e777.JPG@13da2864.42a1fa89]

Le 26/09/2016 � 07:44, Thanos Constantopoulos a �crit :

Odyssey

Dear All

Is there a way to prevent ticket merging when the tickets are not in
the same queue?

you have to override the method RT::Ticket->MergeInto for this.

Here is an (untested) sample code to put in rt/local/lib/RT/Ticket_Local.pm:

package RT::Ticket;

use strict;
no warnings qw(redefine);

my $old_mergeinto = &MergeInto;

*MergeInto = sub {
my $self = shift;
my $ticket_id = shift;

my $MergeInto = RT::Ticket->new($self->CurrentUser);
$MergeInto->Load($ticket_id);

if ( $MergeInto->Id ) {
        if ( $self->Queue != $MergeInto->Queue ) {
             return ( 0, $self->loc("Can't merge tickets from

different queues ([_1], [_2])", $self->QueueObj->Name,
$MergeInto->QueueObj->Name) );
}
}

return $old_mergeinto->($self, @_);

};

1;

if you only take care of the web interface, youb should be able to block
the merge processing using the callback located in
share/html/Ticket/ModifyLinks.html, by looking at posted args, loading
target ticket and checking queues against $TicketObj->Queue. Then if
queues does not match, push a message in @$Results and delete the merge
from $ARGSRef.

Thank you, working perfectly.

Hello!
Can You tell me exactly how can i use this script?
I want to merge all my existing tickets, en all my new tickets.
Thanks