[rt-users] Extract Custom field and merge if Custom Field matches?
Greg Evans
gevans at hcc.net
Wed Nov 12 13:27:56 EST 2008
Hello,
I am working on a problem here in which our after-hours support, with their
own ticketing system submits tickets to our RT via an automated process.
Each ticket comes in with a subject similar to "[1234567] Escalation -
Customer name - Customer Issue"
I am using ExtractCustomField (probably not the exact name there) to extract
the ticket number in brackets from the subject and populate a corresponding
Custom Field in their queue. This part is working properly. L:)
What I am trying to do now, is on each ticket submission, Extract that field
and then check to see if there is another ticket that has that same number
in the custom field and if they match, merge the tickets.
I found this code in the mailing list archives that claims to do so, but it
would appear that it is not running on my system when I try to use it (I am
using 3.8.1 btw)
This is what I did in the scrip:
my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitQueue(VALUE => 'AfterHoursSupport');
$TicketsObj->LimitCustomField(CUSTOMFIELD => 'AfterHoursTicketNumber',
OPERATOR => '=', VALUE => $AHTixNum);
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;
Now, perhaps I put the scrip in incorrectly? I am not sure, so here is how I
put the scrip into the system. Also, maybe something has changed that I am
not aware of that would mean this scrip needs to be written differently at
this point. I have enabled debugging in the scrip, but never see anything in
the log, so this would appear to mean it is either A) Not running or B) not
getting anywhere.
Description : 001-New or Merge After Hours Support
Condition : On Create
Action : User Defined
Template : Global Template: Blank
Stage : TransactionCreate
Custom Condition : n/a // Above code here
Custom Action Preparation code : n/a // Above code here
Custom action Cleanup Code :n/a
I have tried placing the above code in both the Custom Condition and the
Custom Action Preparation Code sections but I cannot seem to get it to run
at all. I am assuming that I have done something incorrectly because I don't
really know what I am doing here, but figured I should ask :-) so that I can
hopefully make it work as intended :-)
Any insight would be appreciated
Greg Evans
Hood Canal Communications
(360) 898-2481 ext.212
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20081112/d937af58/attachment.htm>
More information about the rt-users
mailing list