<div>Thanks Raed. </div>
<div> </div>
<div>I tried you're script but am getting error. </div>
<div> </div>
<div>Jun 12 13:09:54 data1 RT: Scrip 26 Commit failed: Can't locate object method "TicketsObj" via package "RT::Action::UserDefined" at (eval 4184) line 1. Stack: [(eval 4184):1] [/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/Action/UserDefined.pm:81)<br>
<br>there are also errors that are related to syntax (ie missing ; , Ticketobj instead of ticketsobj).</div>
<div> </div>
<div>This is the scrip that I'm running. </div>
<div> </div>
<div>Thanks!</div>
<div> </div>
<div>scrip:</div>
<div> </div>
<div>return undef unless ($self->TicketsObj->Subject =~ / \*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) ;<br>my $subject = $self->TicketsObj->Subject();</div>
<div>my $TicketsObj = RT::Tickets->new($RT::SystemUser);<br>$TicketsObj->LimitQueue(VALUE => 'IT');</div>
<div>$TicketsObj->Limit(FIELD => 'Subject' ,VALUE => $subject , OPERATOR => 'LIKE' ); #This tries to match on the whole subject line</div>
<div>if ($TicketsObj->Count == 0) { return 1; }<br>my $id = undef;<br>while (my $ticket = $TicketsObj->Next) {<br> next if $self->TicketsObj->Id == $ticket->Id;<br> $id = $ticket->Id;<br> last;<br>}<br>
$id || return 1;<br>$RT::Logger->debug("Merging ticket " . $self->TicketsObj->Id . " into $id because of OA number match.");<br>$self->TicketsObj->MergeInto($id);<br>1;<br></div>
<div> </div>
<div> </div>
<div><br> </div>
<div class="gmail_quote">On Fri, Jun 12, 2009 at 10:31 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">1- Your error log:<br>- If you have not a directory /var/log/rt3 , create it and create the file rt.log by touch<br>
touch /var/log/rt3/rt.log<br>then make sure its owned by the user:group running the web server (apache or whatever)<br>-if you have not already make sure you have the below line in RT_SiteConfig<br> Set($LogDir, '/var/log/rt3');<br>
<br>Then restart httpd<br><br>2- Your scrip<br>Why do you need the CF still does n't make since to me?<br>In any case for if subject match then merge you can do : Global/Scrips/New scrip<br><br>Condition: On Create (# so we trigger this when a ticket is created)<br>
Action: User defined<br>Template: Blank<br><br>in Custom action preparation code put:<br>return 1;<br><br>in<br>Custom action cleanup code:<br>return undef unless ($self->TicketObj->Subject =~ / \*\* PROBLEM (\w+) - (.*) (\w+) \*\*/ ) ;<br>
my $subject = $self->TicketObj->Subject()
<div class="im"><br>my $TicketsObj = RT::Tickets->new($RT::SystemUser);<br>$TicketsObj->LimitQueue(VALUE => 'IT');<br></div>$TicketsObj->Limit(FIELD => 'Subject' ,VALUE => $subject , OPERATOR => 'LIKE' ); #This tries to match on the whole subject line
<div class="im"><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 . " into $id because of OA number match.");<br>$self->TicketObj->MergeInto($id);<br>1;<br><br>
</div>Regards;<br><br>Roy<br><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">I just want to merge new tickets with existing tickets with matching subject line.<br> I have been provided with the script below. But getting errors on this line cause the Custom field is not present.<br>
error $TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=', VALUE => $oa);<br> I need to get the ID of the existing ticket and merge the new ticket with this ID.<br> 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<br>
I already add on /opt/rt3/etc/RT_SiteConfig.pm<br> Set($LogToFileNamed , "rt.log");<br>Set($LogToFile , 'debug');<br> and set permissions for the file:<br>touch /opt/rt3/var/log/rt.log<br>chown apache:apache /opt/rt3/var/log/rt.log<br>
Viewing the debug logs will surely help.<br> Thanks for all the help<br>Roehl<br> # from <a href="http://archives.free.net.ph/message/20040319.180325.27528377.en.html" target="_blank">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<br>my $oa = undef;<br>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; }<br><br>my $TicketsObj = RT::Tickets->new($RT::SystemUser);<br>$TicketsObj->LimitQueue(VALUE => 'IT');<br>$TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=', VALUE => $oa);<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 . " into $id because of OA number match.");<br>$self->TicketObj->MergeInto($id);<br>1;<br> <br><br></div></div>
<div>
<div></div>
<div class="h5"> On Fri, Jun 12, 2009 at 9:33 AM, Raed El-Hames <<a href="mailto:rfh@vialtus.com" target="_blank">rfh@vialtus.com</a> <mailto:<a href="mailto:rfh@vialtus.com" target="_blank">rfh@vialtus.com</a>>> wrote:<br>
<br> You answered you are own question , yes you are getting the error<br> because you do not have the custom field<br> Create the custom field and apply it to all queues (unless the<br> 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,<br> I am not sure you need to search on custom fields (considering<br> they don't exist to begin with)<br><br> Roy<br><br> rmp dmd wrote:<br>
<br><br> I changed this<br> $TicketsObj->LimitStatus(VALUE => 'new');<br> $TicketsObj->LimitStatus(VALUE => 'open');<br> to:<br> $TicketsObj->LimitCustomField(CUSTOMFIELD =><br>
'OAReqNum', OPERATOR<br> => '=', VALUE => $oa);<br> but I'm getting error<br> Jun 11 22:13:13 data1 RT: Query error in << ( 'CF.' =<br> '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]<br>
[/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<br> CustomField. I attached<br> our RT interface. Anybody kindly help, identify the problem.<br> My RT interface shows some of this information:<br>
#2345: Re: ** PROBLEM alert - Echo PC02/check_usa is<br> 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> Requestors: <a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a><br>
</div></div> <mailto:<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> <mailto:<a href="mailto:rmp.dmd1229@gmail.com" target="_blank">rmp.dmd1229@gmail.com</a>>><br><br> Thanks!<br> Roehl<br><br> <br> On Thu, Jun 11, 2009 at 3:44 PM, rmp dmd<br>
<<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>><br> <mailto:<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<br>
created<br> tickets to a ticket with status 'new' on the top of<br> the list.<br> I need to merge new ticket to an existing<br> ticket with subject<br> matching ** PROBLEM - any words - CRITICAL ** .<br>
1st request, this is a match: #2316: ** PROBLEM<br> alert - Echo<br> PC02/check_usa is CRITICAL **<br> 2nd request, this is a match: #2317: ** PROBLEM alert -<br> Echo<br>
PC02/check_usa is CRITICAL ** The<br> 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.<br> 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 " .<br> $self->TicketObj->Id .<br> " into $id because of OA number match.");<br>
$self->TicketObj->MergeInto($id);<br> 1;<br><br><br><br><br></div></div></blockquote></blockquote></div><br>