Getting the current queue name and how to move the ticket to another queue?

Hi,

despite reading the RTWiki pages I still don’t know how I can get the
name (not the number) of the queue in which the ticket is in, using
scrip-code. I also cannot find how I can move the ticket from one queue
to the other using the name of the queue.

What I want to do is the following. A ticket comes in, the IP address is
filtered out and a query is made on the database to see to which country
the IP address belongs. That output is stored in a customfield. That all
works fine. I also know how to read the value of a CF. Our queues are
named like f.i. chello abuse AT, chello abuse NL etc. The CF contains
the country code. Our pre-filtering is done by procmail, but because
some people still mail to the wrong abuseaddress, it is possible that a
complaint for chello.at gets into the chello abuse NL queue. Therefor I
want to get the name of the current queue and regexp it to see if
there’s a match (countrycode AT = chello abuse AT?) If the ticket is in
the wrong queue I want to move it to the correct queue.

Can someone tell me how I can:

  • get the name of the current queue into a variable
  • move a ticket to another queue using the name of it

Thank you very much in advance for any response.

Regards,

Marcel Swinkels
chello abuse
UPC Nederland
mswinkels@upc.nl

Swinkels, Marcel wrote:

Hi,

despite reading the RTWiki pages I still don’t know how I can get the
name (not the number) of the queue in which the ticket is in, using
scrip-code. I also cannot find how I can move the ticket from one queue
to the other using the name of the queue.

my $CurrentQueueName = $TicketObj->QueueObj->Name.

my $QueueObj = RT::Queue->new( $self->CurrentUser );
$QueueObj->Load( ‘ToQueueName’ );
unless( $QueueObj->id ) {
die “Can’t load queue”;
}
$TicketObj->SetQueue( $QueueObj->id );

Hi Ruslan,

sorry to bother you again. I tried to use the code you gave me:

my $CurrentQueue;
$CurrentQueue = $TicketObj->QueueObj->Name.
$RT::Logger->info(“Found queuename $CurrentQueue”);

But when I use that code, I get the following error:

Apr 29 09:34:43 secsrv RT: Scrip 66 Prepare failed: Global symbol
“$TicketObj” requires explicit package name at (eval 2067) line 43.
(/opt/rt3/lib/RT/Action/UserDefined.pm:43)

I used this code in a working script that already has the following
declarations:

my $IPaddress;
my $UPCountrycode;
my $CFNameRead = ‘IPaddress’;
my $CFNameWrite = ‘UPCountry’;
my $Ticket = $self->TicketObj;
my $CustomFields = $Ticket->QueueObj->CustomFields();
my $CF = RT::CustomField->new( $RT::SystemUser );

Did I miss a declaration somewhere? I also tried to add ; or . “\n”;,
but none of these options seems to work.

Regards,

Marcel Swinkels
chello abuse
UPC Nederland
mswinkels@upc.nlFrom: Ruslan U. Zakirov [mailto:cubic@acronis.ru]
Sent: zaterdag 24 april 2004 15:12
To: Swinkels, Marcel
Cc: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] getting the current queue name and how to move
the ticket to another queue?

Swinkels, Marcel wrote:

Hi,

despite reading the RTWiki pages I still don’t know how I can get the
name (not the number) of the queue in which the ticket is in, using
scrip-code. I also cannot find how I can move the ticket from one
queue to the other using the name of the queue.

my $CurrentQueueName = $TicketObj->QueueObj->Name.

my $QueueObj = RT::Queue->new( $self->CurrentUser ); $QueueObj->Load(
‘ToQueueName’ ); unless( $QueueObj->id ) {
die “Can’t load queue”;
}
$TicketObj->SetQueue( $QueueObj->id );

What I want to do is the following. A ticket comes in, the IP address
is filtered out and a query is made on the database to see to which
country the IP address belongs. That output is stored in a
customfield. That all works fine. I also know how to read the value of

a CF. Our queues are named like f.i. chello abuse AT, chello abuse NL
etc. The CF contains the country code. Our pre-filtering is done by
procmail, but because some people still mail to the wrong
abuseaddress, it is possible that a complaint for chello.at gets into
the chello abuse NL queue. Therefor I want to get the name of the
current queue and regexp it to see if there’s a match (countrycode AT
= chello abuse AT?) If the ticket is in the wrong queue I want to move

it to the correct queue.

Can someone tell me how I can:

  • get the name of the current queue into a variable
  • move a ticket to another queue using the name of it

Thank you very much in advance for any response.

Regards,

Marcel Swinkels
chello abuse
UPC Nederland
mswinkels@upc.nl _______________________________________________
The rt-users Archives

RT Developer and Administrator training is coming to LA, DC and
Frankfurt this spring and summer.
http://bestpractical.com/services/training.html

Sign up early, as class space is limited.

http://wiki.bestpractical.com/index.cgi?WriteCustomAction
Read first chapter. It’ll give you start point.

Swinkels, Marcel wrote:

Swinkels, Marcel wrote:

Apr 29 09:34:43 secsrv RT: Scrip 66 Prepare failed: Global symbol
“$TicketObj” requires explicit package name at (eval 2067) line 43.
(/opt/rt3/lib/RT/Action/UserDefined.pm:43)

$self->TicketObj …

I used this code in a working script that already has the following
declarations:

my $Ticket = $self->TicketObj;

… or simply $Ticket. :slight_smile: