[rt-users] Still tryin' to merge tix with matching CFs

Jeremy Burke jburke at crypticstudios.com
Wed Feb 18 16:15:03 EST 2009


I have this working in my RT 3.8.2 installation.  It isn't a very busy system and I have yet to notice any performance issues.  We only get about 50 tickets per day and it has less than 5000 tickets in the system.

First, you need to setup and use the RT Extension to extract custom fields. http://search.cpan.org/~alexmv/RT-Extension-ExtractCustomFieldValues-1.8/ (There is a newer version 2.0 out which I have not used yet)

Make sure this scrip runs before the merge scrip.  Otherwise, the custom fields won't be populated to match on.  I did this by naming the scrip "1Add UniqueID Custom Field".

Once you are sure the Custom Field extraction is working, The following scrip should get you started on being able to match and merge on that field.  The Custom Field name I match on is UniqueID.  I omit the check for the queue which is in the previous scrip example you posted.

Description: "2Merge on UniqueID match" (the 2 at the beginning has it run just after the CF extraction)
Condition: OnCreate
Action: User Defined
Template: Global template: Blank
Stage: TransactionCreate

Custom condition: 
<blank>

Custom action preparation code:
1;

Custom action cleanup code:

my $uniqueid = undef;
$uniqueid = $self->TicketObj->FirstCustomFieldValue('UniqueID');
$RT::Logger->debug("My Uniqueid: $uniqueid for search.");

my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitCustomField(CUSTOMFIELD => 'UniqueID', OPERATOR => '=', VALUE => $uniqueid);

if ($TicketsObj->Count == 0) { return 1; }
my $id = undef;
while (my $ticket = $TicketsObj->Next) {
next if $self->TicketObj->Id == $ticket->Id;
$id = $ticket->Id;
$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of UniqueID number match.");
$self->TicketObj->MergeInto($id);
}

$id || return 1; 

1;



More information about the rt-users mailing list