<div dir="ltr"><div class="gmail_default"><div class="gmail_default" style="font-family:verdana,sans-serif">My scrip looks for currently open Incidents that are related to each of the IP addresses in CF.{IP} on an Incident Report. If it finds one it links the Incident Report to that Incident thus making it unnecessary for someone to do it manually later. This might be changed to CustomerID or something later.</div>
<div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Anyway - The snippet from my scrip that I'd like to modify with something more native instead of using RT::Client::REST is the following. Is there a way to search for tickets without using RT::Client::REST? I've been reading through page after page but I'm not able to figure this one out. Is this the only way I'll be able to do it? It works but it logs itself in to RT via the web interface each time a new Incident Report comes in.</div>
<div class="gmail_default" style="font-family:verdana,sans-serif"><br></div><div class="gmail_default"><font face="courier new, monospace">use RT::Client::REST;</font></div><div class="gmail_default"><font face="courier new, monospace">use Error qw(:try);</font></div>
<div class="gmail_default"><font face="courier new, monospace">my $rturl = "http://".RT->Config->Get('WebDomain');</font></div><div class="gmail_default"><font face="courier new, monospace">my $rt = RT::Client::REST->new( server => $rturl, timeout => 30 );</font></div>
<div class="gmail_default"><font face="courier new, monospace">my $user = 'XXXXXX';</font></div><div class="gmail_default"><font face="courier new, monospace">my $pass = 'XXxx11';</font></div><div class="gmail_default">
<font face="courier new, monospace">try {</font></div><div class="gmail_default"><font face="courier new, monospace"> $rt->login(username => $user, password => $pass);</font></div><div class="gmail_default"><font face="courier new, monospace">} catch Exception::Class::Base with {</font></div>
<div class="gmail_default"><font face="courier new, monospace"> die "problem logging in: ", shift->message;</font></div><div class="gmail_default"><font face="courier new, monospace">};</font></div><div class="gmail_default">
<font face="courier new, monospace"><br></font></div><div class="gmail_default"><font face="courier new, monospace">my $ips = $self->TicketObj->CustomFieldValues( 'IP' );</font></div><div class="gmail_default">
<font face="courier new, monospace">while ( my $ipobj = $ips->Next ) {</font></div><div class="gmail_default"><font face="courier new, monospace"> my $ip = $ipobj->Content;</font></div><div class="gmail_default"><font face="courier new, monospace"> $RT::Logger->critical("Searching for open incidents related to ".$ip."\n");</font></div>
<div class="gmail_default"><font face="courier new, monospace"> my $query = qq/Queue = 'Incidents' AND Status = 'open' AND CF.{IP} = '$ip'/;</font></div><div class="gmail_default"><font face="courier new, monospace"> my @ids = $rt->search(</font></div>
<div class="gmail_default"><font face="courier new, monospace"> type => 'ticket',</font></div><div class="gmail_default"><font face="courier new, monospace"> query => $query,</font></div><div class="gmail_default">
<font face="courier new, monospace"> );</font></div><div class="gmail_default"><font face="courier new, monospace"> foreach my $id (@ids) {</font></div><div class="gmail_default"><font face="courier new, monospace"> $RT::Logger->critical("Linking to existing Incident #".$id." for ".$ip."\n");</font></div>
<div class="gmail_default"><font face="courier new, monospace"> $self->TicketObj->AddLink( Type=>'MemberOf', Target=> $id );</font></div><div class="gmail_default"><font face="courier new, monospace"> }</font></div>
</div><font face="courier new, monospace">}</font><br clear="all"><div><br></div><div><br></div>-- <br><div>Landon Stewart <LandonStewart@Gmail.com><br></div>
</div>