[rt-users] help in creating Scrips

Raed El-Hames rfh at vialtus.com
Fri Jun 12 09:33:10 EDT 2009


You answered you are own question , yes you are getting the error 
because you do not have the custom field
Create the custom field and apply it to all queues (unless the scrip 
below is not a global scrip -- but I doubt that--)

Can you explain what you are trying to do, maybe we can help you, I am 
not sure you need to search on custom fields (considering they don't 
exist to begin with)

Roy

rmp dmd wrote:
>
>     I changed this
>      
>     $TicketsObj->LimitStatus(VALUE => 'new');
>     $TicketsObj->LimitStatus(VALUE => 'open');
>      
>     to:
>      
>     $TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR
>     => '=', VALUE => $oa);
>      
>     but I'm getting error
>      
>     Jun 11 22:13:13 data1 RT: Query error in << (  'CF.' = 'alert'  )
>     AND (  'Queue' = 'IT'  ) >>: Unknown field: CF. at
>     /opt/rt3/lib/RT/Tickets_Overlay_SQL.pm line 308.  Stack:  
>     [/opt/rt3/lib/RT/Tickets_Overlay_SQL.pm:308]  
>     [/opt/rt3/lib/RT/Tickets_Overlay_SQL.pm:482]  
>     [/opt/rt3/lib/RT/Tickets_Overlay.pm:2641]  
>     [/opt/rt3/lib/RT/Tickets_Overlay.pm:2314]   [(eval 4308):24]  
>     [/opt/rt3/lib/RT/ScripAction_Overlay.pm:241]  
>     [/opt/rt3/lib/RT/Scrip_Overlay.pm:507]  
>     [/opt/rt3/lib/RT/Scrips_Overlay.pm:192]  
>     [/opt/rt3/lib/RT/Transaction_Overlay.pm:170]  
>     [/opt/rt3/lib/RT/Record.pm:1438]  
>     [/opt/rt3/lib/RT/Ticket_Overlay.pm:720]  
>     [/opt/rt3/lib/RT/Interface/Email.pm:765]  
>     [/opt/rt3/share/html/REST/1.0/NoAuth/mail-gateway:58] 
>     (/opt/rt3/lib/RT/Tickets_Overlay_SQL.pm:484)
>      
>      
>     'm guessing, this is because I do not a CustomField. I attached
>     our RT interface. Anybody kindly help, identify the problem.
>      
>
>  
> My RT interface shows some of this information:
>  
>  
>  #2345: Re: ** PROBLEM alert - Echo PC02/check_usa is CRITICAL **
> *Ticket metadata*
>     The Basics:
>       Id: 2345
>      Status: new
>      Left: 0 min
>      Priority: 60/0
>      Queue: IT
>    Custom Fields:
>       Machine Name: No Value
>       Customer: No Value
>   People:
>       Owner: Nobody
>       Requestors: rmp.dmd1229 at gmail.com <mailto:rmp.dmd1229 at gmail.com>
>  
>  
>  
>
>     Thanks!
>     Roehl
>
>  
>
>
>     On Thu, Jun 11, 2009 at 3:44 PM, rmp dmd <rmp.dmd1229 at gmail.com
>     <mailto:rmp.dmd1229 at gmail.com>> wrote:
>
>         Thank you very much Raed.
>          
>         This problem explains while I merging the newly created
>         tickets to a ticket with status 'new'  on the top of the list.
>          
>         I need to merge new ticket to an existing ticket with subject
>         matching ** PROBLEM - any words - CRITICAL ** .
>          
>         1st request, this is a match: #2316: ** PROBLEM alert - Echo
>         PC02/check_usa is CRITICAL **
>         2nd request, this is a match: #2317: ** PROBLEM alert - Echo
>         PC02/check_usa is CRITICAL ** 
>          
>         The existing ticket has an ID: 2312 with Subject: ** PROBLEM
>         alert - Echo PC02/check_usa is CRITICAL ** 
>          
>         I will merge ticket 2316 and 2317 with 2312.
>          
>         Somehow this merge to a ticket DRP with ID 720.  This is
>         ticket is on the top of IT queue list
>          
>         223 Centralize Sever login   open IT
>         668 test on Saturn             open  IT
>         720 DRP                           new  IT
>         745 Backup - all corporate  open  IT
>         873 Image Ken Gen           open  IT
>         1135 DSS-3 tapes             new  IT
>          
>         Below is the script.  I hope somebody can help.
>          
>         Thanks!
>         Roehl
>          
>         my $oa = undef;
>         my $Transaction = $self->TransactionObj;
>         my $subject =
>         $Transaction->Attachments->First->GetHeader('Subject');
>         if ( $subject =~ /\*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) {
>         $oa = $1;
>         #$RT::Logger->debug("Found oa: $oa");
>         }
>         else { return 1; }
>
>         my $TicketsObj = RT::Tickets->new($RT::SystemUser);
>         $TicketsObj->LimitQueue(VALUE => 'IT');
>         $TicketsObj->LimitStatus(VALUE => 'new');
>         $TicketsObj->LimitStatus(VALUE => 'open');
>          
>          
>         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;
>
>
>



More information about the rt-users mailing list