[rt-users] scrip questions
Todd Chapman
rt at chaka.net
Fri Mar 19 13:03:25 EST 2004
Here is my scrip. You might also want to add a call to
SetStatus at the end: $self->TicketObj->SetStatus('resolved')
Description: Merge Into Existing Ticket on match
Condition: OnCreate
Action: User Defined
Custom action preparation code:
1;
Custom action cleanup code:
=======================================
# If the subject of the ticket matches a pattern suggesting
# that an OA request number is in the subject AND there is
# an existing ticket is the OAReq queue with a matching
# OAReqNum custom field, (that is not this ticket)
# merge this ticket into that ticket
my $oa = undef;
my $Transaction = $self->TransactionObj;
my $subject = $Transaction->Attachments->First->GetHeader('Subject');
#if ($subject =~ /(Pending|Approved|Fulfilled)\s*\#\s*(\d\d\d\d\d\d?)/) {
if ($subject =~ /\D*(\d\d\d\d\d\d?)\D*/) {
$oa = $1;
#$RT::Logger->debug("Found oa: $oa");
}
else { return 1; }
my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitQueue(VALUE => 'Test');
$TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=', VALUE => $oa);
if ($TicketsObj->Count == 0) { return 1; }
my $id = undef;
while (my $ticket = $TicketsObj->Next) {
next if $self->TicketObj->Id == $ticket->Id;
$id = $ticket->Id;
last;
}
$id || return 1;
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match.");
$self->TicketObj->MergeInto($id);
1;
=======================================
Stage: TransactionCreate
Template: Global template: Blank
On Fri, Mar 19, 2004 at 08:19:28PM +0200, Subredu Manuel wrote:
>
>
> Todd Chapman wrote:
> >How can you match the Recovery ticket with the Problem
> >ticket? Is there an ID in the subject or someting unique
> >you can use?
> >
>
> yes. the subject of the mail gives me the informations I need to match
> tickets.
>
> >My system gets e-mail from a different (horrible, horrible)
> >ticketing system. Where store the ID from the foreign system
> >into a custom field. If a new ticket comes in and it has
> >an ID in the subject that matches an existing ticket custom
> >field, we merge the new ticket into the old one.
>
> Can you give some hints about this ? If you can provide the scrip it's
> awsome :D
>
> >
> >-Todd
> >
> _______________________________________________
> rt-users mailing list
> rt-users at lists.bestpractical.com
> http://lists.bestpractical.com/mailman/listinfo/rt-users
>
> Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm
More information about the rt-users
mailing list