<div>I just want to merge new tickets with existing tickets with matching subject line. </div>
<div> </div>
<div>I have been provided with the script below. But getting errors on this line cause the Custom field is not present. </div>
<div> </div>
<div>error $TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=', VALUE => $oa);</div>
<div> </div>
<div>I need to get the ID of the existing ticket and merge the new ticket with this ID. </div>
<div> </div>
<div>The scrip also has $RT::Logger->debug but I can not see anything on /opt/rt3/var/log/rt.log.  I only see errors on /var/log/messages </div>
<div> </div>
<div>I already add on /opt/rt3/etc/RT_SiteConfig.pm</div>
<div> </div>
<div>Set($LogToFileNamed , "rt.log");<br>Set($LogToFile      , 'debug');</div>
<div> </div>
<div>and set permissions for the file: </div>
<div>touch /opt/rt3/var/log/rt.log<br>chown apache:apache /opt/rt3/var/log/rt.log<br></div>
<div>Viewing the debug logs will surely help. </div>
<div> </div>
<div>Thanks for all the help </div>
<div>Roehl</div>
<div> </div>
<div># from <a href="http://archives.free.net.ph/message/20040319.180325.27528377.en.html">http://archives.free.net.ph/message/20040319.180325.27528377.en.html</a><br>#<br># If the subject of the ticket matches a pattern suggesting <br>
# that an OA request number is in the subject AND there is <br># an existing ticket is the OAReq queue with a matching <br># status field, (that is not this ticket) <br># merge this ticket into that ticket </div>
<div>my $oa = undef; </div>
<div>my $Transaction = $self->TransactionObj; <br>my $subject = $Transaction->Attachments->First->GetHeader('Subject'); <br>if ( $subject =~ /\*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) {<br>$oa = $1; <br>
$RT::Logger->debug("Found oa: $oa"); <br>} <br>else { return 1; } </div>
<div><br>my $TicketsObj = RT::Tickets->new($RT::SystemUser); <br>$TicketsObj->LimitQueue(VALUE => 'IT');<br>$TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=', VALUE => $oa); </div>

<div>if ($TicketsObj->Count == 0) { return 1; } <br>my $id = undef; <br>while (my $ticket = $TicketsObj->Next) { <br>next if $self->TicketObj->Id == $ticket->Id; <br>$id = $ticket->Id; <br>last; <br>} </div>

<div>$id || return 1; </div>
<div>$RT::Logger->debug("Merging ticket " . $self->TicketObj->Id . " into $id because of OA number match."); <br>$self->TicketObj->MergeInto($id); <br>1; </div>
<div> </div>
<div><br><br> </div>
<div class="gmail_quote">On Fri, Jun 12, 2009 at 9:33 AM, Raed El-Hames <span dir="ltr"><<a href="mailto:rfh@vialtus.com">rfh@vialtus.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">You answered you are own question , yes you are getting the error because you do not have the custom field<br>
Create the custom field and apply it to all queues (unless the scrip below is not a global scrip -- but I doubt that--)<br><br>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)<br>
<br>Roy<br><br>rmp dmd wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div></div>
<div class="h5"><br>   I changed this<br>       $TicketsObj->LimitStatus(VALUE => 'new');<br>   $TicketsObj->LimitStatus(VALUE => 'open');<br>       to:<br>       $TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR<br>
   => '=', VALUE => $oa);<br>       but I'm getting error<br>       Jun 11 22:13:13 data1 RT: Query error in << (  'CF.' = 'alert'  )<br>   AND (  'Queue' = 'IT'  ) >>: Unknown field: CF. at<br>
   /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)<br>
           'm guessing, this is because I do not a CustomField. I attached<br>   our RT interface. Anybody kindly help, identify the problem.<br>    <br> My RT interface shows some of this information:<br>   #2345: Re: ** PROBLEM alert - Echo PC02/check_usa is CRITICAL **<br>
*Ticket metadata*<br>   The Basics:<br>     Id: 2345<br>    Status: new<br>    Left: 0 min<br>    Priority: 60/0<br>    Queue: IT<br>  Custom Fields:<br>     Machine Name: No Value<br>     Customer: No Value<br> People:<br>
     Owner: Nobody<br></div></div>     Requestors: <a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a> <mailto:<a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a>> 
<div class="im"><br>   <br>   Thanks!<br>   Roehl<br><br> <br><br>   On Thu, Jun 11, 2009 at 3:44 PM, rmp dmd <<a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a><br></div>
<div>
<div></div>
<div class="h5">   <mailto:<a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a>>> wrote:<br><br>       Thank you very much Raed.<br>               This problem explains while I merging the newly created<br>
       tickets to a ticket with status 'new'  on the top of the list.<br>               I need to merge new ticket to an existing ticket with subject<br>       matching ** PROBLEM - any words - CRITICAL ** .<br>               1st request, this is a match: #2316: ** PROBLEM alert - Echo<br>
       PC02/check_usa is CRITICAL **<br>       2nd request, this is a match: #2317: ** PROBLEM alert - Echo<br>       PC02/check_usa is CRITICAL **                The existing ticket has an ID: 2312 with Subject: ** PROBLEM<br>
       alert - Echo PC02/check_usa is CRITICAL **                I will merge ticket 2316 and 2317 with 2312.<br>               Somehow this merge to a ticket DRP with ID 720.  This is<br>       ticket is on the top of IT queue list<br>
               223 Centralize Sever login   open IT<br>       668 test on Saturn             open  IT<br>       720 DRP                           new  IT<br>       745 Backup - all corporate  open  IT<br>       873 Image Ken Gen           open  IT<br>
       1135 DSS-3 tapes             new  IT<br>               Below is the script.  I hope somebody can help.<br>               Thanks!<br>       Roehl<br>               my $oa = undef;<br>       my $Transaction = $self->TransactionObj;<br>
       my $subject =<br>       $Transaction->Attachments->First->GetHeader('Subject');<br>       if ( $subject =~ /\*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) {<br>       $oa = $1;<br>       #$RT::Logger->debug("Found oa: $oa");<br>
       }<br>       else { return 1; }<br><br>       my $TicketsObj = RT::Tickets->new($RT::SystemUser);<br>       $TicketsObj->LimitQueue(VALUE => 'IT');<br>       $TicketsObj->LimitStatus(VALUE => 'new');<br>
       $TicketsObj->LimitStatus(VALUE => 'open');<br>                       if ($TicketsObj->Count == 0) { return 1; }<br>       my $id = undef;<br>       while (my $ticket = $TicketsObj->Next) {<br>       next if $self->TicketObj->Id == $ticket->Id;<br>
       $id = $ticket->Id;<br>       last;<br>       }<br>       $id || return 1;<br>       $RT::Logger->debug("Merging ticket " . $self->TicketObj->Id .<br>       " into $id because of OA number match.");<br>
       $self->TicketObj->MergeInto($id);<br>       1;<br><br><br><br></div></div></blockquote></blockquote></div><br>