[rt-users] Applying the RTIR_FindIP.pm when changing queues instead of On Create

Landon landonstewart at gmail.com
Wed Jun 26 12:59:43 EDT 2013

Hello RT Users,

We have a *ton* of tickets in a queue from another instance of RT in our
instance of RTIR (RT4/RTIR3).  I've been able to modify the Lifecycles so
that I can move tickets to the "Incident Reports" queue now (thanks Kevin
for your advice with that).  I'd like tickets moved to that queue treated
like new Incident Report tickets in RTIR but hitting some snags.

The condition for On Queue Change itself isn't a problem since that part is
pretty straight forward (either using the built in "On Queue Change" or a
user defined condition).

The problem is that the provided "SetIPFromContent" (which presumably is
the RTIR_FindIP.pm) doesn't work when using "On Queue Change" as a
condition.  This is probably because the content of the transaction is that
of a queue change and does not contain any correspondence-style content and
it's not something you can run against the action.  What I need however is
something that will run against each part (attachment?) of this already
existing ticket.

I attempted to do this using a simple loop over each of the transactions
but it's kind of hacked up and the loop doesn't even seem to run once (as
if there are no transactions with attachments).

*As a test I made the following scrip *but* I'd like something more native
to RTIR_FindIP.pm if possible.  *

NAME: OnQueueChange Find IPs
Condition: On Queue Change
Action: User Defined
Template: Blank
Stage: Transaction Create

Condition and Preperation: "return 1;"

Cleanup Code:

use Regexp::Common qw(net);
use NetAddr::IP;
use Data::Validate::IP qw(is_ipv4 is_ipv6);

my $attachments = $self->TransactionObj->Attachments;
my @ourips = RT->Config->Get('OurIPs');
my $CF_Obj = RT::CustomField->new($RT::SystemUser);
$CF_Obj->LoadByName( Name => "URL" );    # *** See note
my @inserted;

# Loop over each attachment in the TransactionObj and trap IPv4 and IPv6
# Insert those into the "IP" CustomField.
# *** Note - For testing I've changed it to URL and I'm trying to simply
write \
# ***      - the word "TEST" instead.
# ***      - URL is a valid CF and this AddValueForObject works outside the
# ***      - while loop below.
while (my $message = $attachments->Next) {
  next unless $message->ContentType =~
  my $content = $message->Content;
  my @lines = split(/\n/,$content);
  foreach my $line (@lines) {
    if ($line =~ /($RE{net}{IPv4}|$RE{net}{IPv6})/g) {
      $CF_Obj->AddValueForObject( Object  => $self->TicketObj, Content =>
"TEST" )
          unless grep($1, at inserted);    # *** See note

I've been banging my head against this for a few hours now and can't get
the loop to work it seems let alone find a way to do this more natively
with RTIR_FindIP.pm.

Thanks for reading!

Landon Stewart <LandonStewart at Gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130626/13472ec1/attachment.htm>

More information about the rt-users mailing list