[rt-users] How to search in a Scrip?
Todd Chapman
rt at chaka.net
Fri Mar 12 14:45:52 EST 2004
Answering my own question thanks to:
http://lists.fsck.com/pipermail/rt-devel/2003-August/004667.html
This is what I did in the scrip:
my $TicketsObj = RT::Tickets->new($RT::SystemUser);
$TicketsObj->LimitQueue(VALUE => 'Test');
$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, Mar 12, 2004 at 12:53:55PM -0500, Todd Chapman wrote:
> RT-3.0.9
>
> I am writing an OnCreate scrip that will search the
> content of the ticket for a certain value. If found
> I want to search a queue for the first ticket with
> that value in a certain custom field. If I find
> a matching ticket I will then merge the new ticket
> into it.
>
> What I know how to do:
> -Search content of new ticket
> -Merge new ticket
>
> What I don't know how to do:
> -Build a seach for a ticket
>
> Do I just call RT::Tickets->new followed
> by a few calls to LimitQueue and LimitCustomField
> and finally loop through the tickets?
>
>
> Anyone have a code sample to get me started?
>
> Thanks!
>
> -Todd
>
> _______________________________________________
> rt-users mailing list
> rt-users at lists.bestpractical.com
> http://lists.bestpractical.com/mailman/listinfo/rt-users
>
> Have you read the FAQ? The RT FAQ Manager lives at http://fsck.com/rtfm
More information about the rt-users
mailing list