[rt-users] Change Queue

Landon Stewart lstewart at iweb.com
Thu Sep 26 18:56:59 EDT 2013


On 26 September 2013 10:45, Bryon Baker <bbaker at copesan.com> wrote:

> Ok tried something on my own I copied "SetPriority.pm" module to
> ChangeQueue.pm and change code to
>
> When I try and execute this with rt-crontool I get
>
> [Thu Sep 26 17:39:21 2013] [critical]: Failed to load module
> RT::Action::ChangeQueue. () at /usr/bin/rt-crontool line 305.
> (/usr/lib/perl5/vendor_perl/5.16.2/RT.pm:400)
> Failed to load module RT::Action::ChangeQueue. () at /usr/bin/rt-crontool
> line 305.
>
> I have compared the permissions on both file and everything looks the same.
>
> package RT::Action::ChangeQueue;
> use base 'RT::Action';
>
> use strict;
> use warnings;
>
> #Do what we need to do and send it out.
>
> #What does this type of Action does
>
> sub Describe  {
>   my $self = shift;
>   return (ref $self . " will set a ticket's priority to the argument
> provided.");
>

That looks weird…  ref $self?  That'd probably return "HASH will set
ticket's…" or something.  I'd nuke it entirely anyway since you don't need
this sub.


> sub Prepare  {
>     # nothing to prepare
>     return 1;
> }
>

Nuke this since you don't need it.


> sub Commit {
>     my $self = shift;
>     my $currentqueue = $*ticket*->Queue;
>

You haven't dereferenced $self->TicketObj into $ticket yet above.


> ##  Did this to validate what is happening before I do it.
>     print "Current Queue $currentqueue, New Queue *$self->Argument*\n";
> #    $self->TicketObj->SetQueue($self->Argument);
>
> }
>

This print line would be interpreted as:
print "Current Queue ".$currentqueue.", New Queue ".$self."->Argument\n";

Probably not what you want…

*By the way there might already be an action called SetQueue.pm in your
lib/RT/Actions/ directory.*

If you want to keep working on your module though - try this.
 This ChangeQueue.pm should be located in /opt/rt4/lib/RT/Action/ or
equivalent.  I've removed SetQueue() like you did so it won't actually
modify the ticket.

package RT::Action::ChangeQueue;
use base 'RT::Action';

use strict;
use warnings;

sub Commit {
    my $self = shift;
    my $ticket = $self->TicketObj;
    my $cq = $ticket->Queue;
    my $nq = $self->Argument;

    print "Current Queue $cq, New Queue $nq\n";
    # or
    print "Current Queue ".$self->TicketObj->Queue.", New Queue
".$self->Argument."\n";
    # or
    print "Current Queue ".$ticket->Queue.", New Queue
".$self->Argument."\n";
}

RT::Base->_ImportOverlays();

1;

Give this line a new Queue ID# and a ticket # and watch the magic:
/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --action
RT::Action::ChangeQueue --action-arg "<qid>" --transaction first --verbose
--search-arg 'id = <ticketid>'


-- 
Landon Stewart :: lstewart at iweb.com
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com :: +1 (888) 909-4932
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130926/2b051f0c/attachment.html>


More information about the rt-users mailing list