[rt-users] help in creating Scrips
rmp dmd
rmp.dmd1229 at gmail.com
Fri Jun 12 10:06:53 EDT 2009
I just want to merge new tickets with existing tickets with matching subject
line.
I have been provided with the script below. But getting errors on this line
cause the Custom field is not present.
error $TicketsObj->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR =>
'=', VALUE => $oa);
I need to get the ID of the existing ticket and merge the new ticket with
this ID.
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
I already add on /opt/rt3/etc/RT_SiteConfig.pm
Set($LogToFileNamed , "rt.log");
Set($LogToFile , 'debug');
and set permissions for the file:
touch /opt/rt3/var/log/rt.log
chown apache:apache /opt/rt3/var/log/rt.log
Viewing the debug logs will surely help.
Thanks for all the help
Roehl
# from http://archives.free.net.ph/message/20040319.180325.27528377.en.html
#
# If the subject of the ticket matches a pattern suggesting
# that an OA request number is in the subject AND there is
# an existing ticket is the OAReq queue with a matching
# status field, (that is not this ticket)
# merge this ticket into that ticket
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->LimitCustomField(CUSTOMFIELD => 'OAReqNum', OPERATOR => '=',
VALUE => $oa);
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;
On Fri, Jun 12, 2009 at 9:33 AM, Raed El-Hames <rfh at vialtus.com> wrote:
> 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;
>>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20090612/50eecdf4/attachment.htm>
More information about the rt-users
mailing list