[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rt-users
Subject:    Re: [rt-users] Change Queue
From:       Bryon Baker <bbaker () copesan ! com>
Date:       2013-09-27 0:55:54
Message-ID: c9ec5a4dc8a1496f8d7948c0865f35ab () DM2PR05MB430 ! namprd05 ! prod ! outlook ! com
[Download RAW message or body]

Thanks Landon for the tips and info.  The suggestions are working great and I am \
moving on.

Also by the way there is not an action of this type in the actions directory.

Again Thanks

Bryon Baker
Network Operations Manager
Copesan - Specialists in Pest Solutions
800-267-3726  *  262-783-6261 ext. 2296
bbaker@copesan.com<mailto:cstephan@copesan.com>
www.copesan.com<http://www.copesan.com/>
"Servicing North America with Local Care"

From: Landon Stewart [mailto:lstewart@iweb.com]
Sent: Thursday, September 26, 2013 5:57 PM
To: Bryon Baker
Cc: RT Users
Subject: Re: [rt-users] Change Queue

On 26 September 2013 10:45, Bryon Baker \
<bbaker@copesan.com<mailto:bbaker@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@iweb.com<mailto:lstewart@iweb.com>
Lead Specialist, Abuse and Security Management
Spécialiste principal, gestion des abus et sécurité
http://iweb.com :: +1 (888) 909-4932


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri","sans-serif";}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Thanks \
Landon for the tips and info.&nbsp; The suggestions are working great and I am moving \
on.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Also \
by the way there is not an action of this type in the actions \
directory.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D">Again \
Thanks<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black">Bryon \
Baker<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black">Network \
Operations Manager<o:p></o:p></span></p> <p class="MsoNormal"><b><i><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:red">Copesan</span></i></b><b><i><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black"> \
- Specialists in Pest Solutions<o:p></o:p></span></i></b></p> <p \
class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black">800-267-3726&nbsp; \
&#8226;&nbsp; 262-783-6261 ext. 2296<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#1F497D"><a \
href="mailto:cstephan@copesan.com">bbaker@copesan.com</a><o:p></o:p></span></p> <p \
class="MsoNormal"><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:black"><a \
href="http://www.copesan.com/"><span \
style="color:black">www.copesan.com</span></a><o:p></o:p></span></p> <p \
class="MsoNormal"><b><i><span \
style="font-size:10.0pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:red">&quot;Servicing \
North America with Local Care&quot;</span></i></b><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p></o:p></span></p>
 <p class="MsoNormal"><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;color:#1F497D"><o:p>&nbsp;</o:p></span></p>
 <p class="MsoNormal"><b><span \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;">From:</span></b><span \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;"> \
Landon Stewart [mailto:lstewart@iweb.com] <br>
<b>Sent:</b> Thursday, September 26, 2013 5:57 PM<br>
<b>To:</b> Bryon Baker<br>
<b>Cc:</b> RT Users<br>
<b>Subject:</b> Re: [rt-users] Change Queue<o:p></o:p></span></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">On 26 September 2013 10:45, Bryon Baker &lt;<a \
href="mailto:bbaker@copesan.com" target="_blank">bbaker@copesan.com</a>&gt; \
wrote:<o:p></o:p></p> <p class="MsoNormal">Ok tried something on my own I copied \
&quot;SetPriority.pm&quot; module to ChangeQueue.pm and change code to<br> <br>
When I try and execute this with rt-crontool I get<br>
<br>
[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)<br> Failed to load module \
RT::Action::ChangeQueue. () at /usr/bin/rt-crontool line 305.<br> <br>
I have compared the permissions on both file and everything looks the same.<br>
<br>
package RT::Action::ChangeQueue;<br>
use base 'RT::Action';<br>
<br>
use strict;<br>
use warnings;<br>
<br>
#Do what we need to do and send it out.<br>
<br>
#What does this type of Action does<br>
<br>
sub Describe &nbsp;{<br>
&nbsp; my $self = shift;<br>
&nbsp; return (ref $self . &quot; will set a ticket's priority to the argument \
provided.&quot;);<o:p></o:p></p> <div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">That looks weird&#8230; &nbsp;ref $self? &nbsp;That'd probably \
return &quot;HASH will set ticket's&#8230;&quot; or something. &nbsp;I'd nuke it \
entirely anyway since you don't need this sub.<o:p></o:p></p> </div>
<div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in \
6.0pt;margin-left:4.8pt;margin-right:0in"> <p class="MsoNormal">sub Prepare \
&nbsp;{<br> &nbsp; &nbsp; # nothing to prepare<br>
&nbsp; &nbsp; return 1;<br>
}<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Nuke this since you don't need it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in \
6.0pt;margin-left:4.8pt;margin-right:0in"> <p class="MsoNormal">sub Commit {<br>
&nbsp; &nbsp; my $self = shift;<br>
&nbsp; &nbsp; my $currentqueue = $<b>ticket</b>-&gt;Queue;<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">You haven't dereferenced $self-&gt;TicketObj into $ticket yet \
above.<o:p></o:p></p> </div>
<div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in \
6.0pt;margin-left:4.8pt;margin-right:0in"> <p class="MsoNormal">## &nbsp;Did this to \
validate what is happening before I do it.<br> &nbsp; &nbsp; print &quot;Current \
Queue $currentqueue, New Queue <b>$self-&gt;Argument</b>\n&quot;;<br> # &nbsp; \
&nbsp;$self-&gt;TicketObj-&gt;SetQueue($self-&gt;Argument);<br> <br>
}<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">This print line would be interpreted as:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">print &quot;Current Queue &quot;.$currentqueue.&quot;, New Queue \
&quot;.$self.&quot;-&gt;Argument\n&quot;; &nbsp;<o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Probably not what you want&#8230; &nbsp;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><b><u>By the way there might already be an action \
called&nbsp;SetQueue.pm in your lib/RT/Actions/ directory.</u></b><o:p></o:p></p> \
</div> <div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">If you want to keep working on your module though - try this. \
&nbsp;This&nbsp;ChangeQueue.pm should be located in /opt/rt4/lib/RT/Action/ or \
equivalent. &nbsp;I've removed SetQueue() like you did so it won't actually modify \
the ticket.<o:p></o:p></p> </div>
<div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">package \
RT::Action::ChangeQueue;<br> use base 'RT::Action';<br>
<br>
use strict;<br>
use warnings;<br>
<br>
sub Commit {<br>
&nbsp; &nbsp; my $self = shift;</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; \
my $ticket = $self-&gt;TicketObj;<br> &nbsp; &nbsp; my $cq = \
$ticket-&gt;Queue;</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; \
my $nq = $self-&gt;Argument;</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><br>
&nbsp; &nbsp; print &quot;Current Queue $cq, New Queue \
$nq\n&quot;;</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; \
# or</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; \
print &quot;Current Queue &quot;.$self-&gt;TicketObj-&gt;Queue.&quot;, New Queue \
&quot;.$self-&gt;Argument.&quot;\n&quot;;</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; &nbsp; \
# or</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;">&nbsp; \
&nbsp;&nbsp;print &quot;Current Queue &quot;.$ticket-&gt;Queue.&quot;, New Queue \
&quot;.$self-&gt;Argument.&quot;\n&quot;;</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier \
New&quot;">}</span><o:p></o:p></p> </div>
<div>
<p class="MsoNormal"><span style="font-family:&quot;Courier New&quot;"><br>
RT::Base-&gt;_ImportOverlays();<br>
<br>
1;</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal">Give this line a new Queue ID# and a ticket # and watch the \
magic:<o:p></o:p></p> </div>
<div>
<p class="MsoNormal">/opt/rt4/bin/rt-crontool --search RT::Search::FromSQL --action \
RT::Action::ChangeQueue --action-arg &quot;&lt;qid&gt;&quot; --transaction first \
--verbose --search-arg 'id = &lt;ticketid&gt;'<o:p></o:p></p> </div>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><span \
style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Landon Stewart :: \
</span><a href="mailto:lstewart@iweb.com" target="_blank"><span \
style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">lstewart@iweb.com</span></a><o:p></o:p></p>
 </div>
<p class="MsoNormal"><span \
style="font-family:&quot;Arial&quot;,&quot;sans-serif&quot;">Lead Specialist, Abuse \
and Security Management<br> Spécialiste principal, gestion des abus et sécurité<br>
<a href="http://iweb.com" target="_blank">http://iweb.com</a> :: &#43;1 (888) \
909-4932</span><o:p></o:p></p> <div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>



-- 
RT Training in New York, October 8th and 9th: http://bestpractical.com/training
--===============0046643966==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic