[Rtir] Using ->DeleteCustomFieldValue() on the 'IP' CF does not work like ->AddCustomFieldValue() ?
Landon Stewart
lstewart at iweb.com
Fri Aug 8 14:34:13 EDT 2014
Hello RTIR,
I've borrowed the code from RTIR_FindIP.pm and modified it so I can specify
the ticket object to Add and Delete IP addresses. This is so I can iterate
through child tickets of an Incident and perform the same action on them.
I can add IP addresses to CF.{IP} but not delete IP addresses though. I'm
stumped. Any clues about how to *delete* an IP address from the IP custom
field?
*This works:* (%existing is a hash where each key is an IP address already
in the CF)
$self->AddIP( Ticket => $ticket, IP => $ipaddr, CustomField => $cf, Skip =>
\%existing );
sub AddIP {
my $self = shift;
my %arg = ( CustomField => undef, IP => undef, Skip => {}, @_ );
return 0 if !$arg{'IP'} || $arg{'Skip'}->{ $arg{'IP'} }++ ||
$arg{'Skip'}->{ $arg{'IP'} .'-'. $arg{'IP'} }++;
my $t = $arg{'Ticket'};
my ($status, $msg) = $t->AddCustomFieldValue( Value => $arg{'IP'},
Field => $arg{'CustomField'}, );
RT->Logger->error("Couldn't add IP address: $msg") unless $status;
return 1;
}
*The code that errors out:* (%keep is a hash where each key is a list of IP
addresses not to delete)
$spots_left += $self->RemIP( Ticket => $ticket, IP => $_, CustomField =>
$cf, Skip => \%keep );
sub RemIP {
my $self = shift;
my %arg = ( CustomField => undef, IP => undef, Skip => {}, @_ );
return 0 if !$arg{'IP'} || $arg{'Skip'}->{ $arg{'IP'} }++ ||
$arg{'Skip'}->{ $arg{'IP'} .'-'. $arg{'IP'} }++;
my $t = $arg{'Ticket'};
my ($status, $msg) = $t->DeleteCustomFieldValue( Value => $arg{'IP'},
Field => $arg{'CustomField'}, );
RT->Logger->error("Couldn't remove IP address: $msg") unless $status;
return 1;
}
*The error:*
RT::CustomField::ParseIPRange Unimplemented in RT::ObjectCustomFieldValue.
(/opt/rt4/bin/../lib/RT/ObjectCustomFieldValue.pm line 169)
Commenting out DeleteCustomFieldValue() line and the logger line make the
error not happen so I'm sure that line is the problem one.
Thank you for reading!
--
Landon Stewart :: lstewart at iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com :: +1 (888) 909-4932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rtir/attachments/20140808/e18c2b6a/attachment.html>
More information about the rtir
mailing list