https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&feed=atom&action=history
AutoSetOwnerForQueue - Revision history
2024-03-29T13:42:13Z
Revision history for this page on the wiki
MediaWiki 1.37.2
https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&diff=277&oldid=prev
Admin: 4 revisions imported
2016-04-06T20:03:18Z
<p>4 revisions imported</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 16:03, 6 April 2016</td>
</tr>
<!-- diff cache key bestpractical_mediawiki1459887241:diff::1.12:old-276:rev-277 -->
</table>
Admin
https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&diff=276&oldid=prev
66.63.81.145: The last line of the scrip was outside the code block.
2012-11-28T19:24:14Z
<p>The last line of the scrip was outside the code block.</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 15:24, 28 November 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l21">Line 21:</td>
<td colspan="2" class="diff-lineno">Line 21:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>Custom Action Preparation: </div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>Custom Action Preparation:</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> return 1;</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l38">Line 38:</td>
<td colspan="2" class="diff-lineno">Line 38:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> unless( $status ) {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> unless( $status ) {</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $RT::Logger-&gt;warning( "Impossible to assign the ticket to $MyUser: $msg" );</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $RT::Logger-&gt;warning( "Impossible to assign the ticket to $MyUser: $msg" );</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> return undef; </div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> return undef;</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>} 1;</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>} 1;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>And that's it. Now you can send an email to [mailto:hardware@yoursite.com hardware@yoursite.com] and a ticket will be automatically created in the queue hardware and assigned to Joe. Thanks Joe, now come fix my !@##$# mouse!</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>And that's it. Now you can send an email to [mailto:hardware@yoursite.com hardware@yoursite.com] and a ticket will be automatically created in the queue hardware and assigned to Joe. Thanks Joe, now come fix my !@##$# mouse!</div></td></tr>
<!-- diff cache key bestpractical_mediawiki1459887241:diff::1.12:old-275:rev-276 -->
</table>
66.63.81.145
https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&diff=275&oldid=prev
99.224.22.98: Cleaned up Wiki formatting
2011-01-07T19:54:30Z
<p>Cleaned up Wiki formatting</p>
<p><b>New page</b></p><div>Say you want all the requests for new hardware to go to the queue "hardware" and be assigned to Joe the hardware guy. If so, this page is for you.<br />
<br />
'''The procedure involves 3 actions:'''<br />
<br />
1. Creating the queue "hardware"<br />
<br />
2. Adding the following email alias<br />
<br />
hardware: |/usr/local/rt3/bin/rt-mailgate --queue hardware --action correspond --url http://rt.yoursite.com/<br />
<br />
3. Creating this Global scrip<br />
<br />
Description: Assign Hardware Requests to Joe<br />
Condition: On Create<br />
Action: User Defined<br />
Template: Global Template: Blank<br />
Stage: TransactionCreate<br />
<br />
Custom Condition:<br />
<br />
return 1;<br />
<br />
Custom Action Preparation: <br />
<br />
return 1;<br />
<br />
Custom Action Cleanup Code:<br />
<br />
my %owners = ( 'hardware' =&gt; 'joe',); <br />
my $QueueName = $self-&gt;TicketObj-&gt;QueueObj-&gt;Name; <br />
return 1 unless defined($owners{$QueueName}); <br />
my $Actor = $self-&gt;TransactionObj-&gt;Creator; <br />
return 1 if $Actor == $RT::SystemUser-&gt;id; <br />
return 1 unless $self-&gt;TicketObj-&gt;Owner == $RT::Nobody-&gt;id; <br />
my $MyUser = $owners{$QueueName}; <br />
$RT::Logger-&gt;info("Auto assigning ticket #". $self-&gt;TicketObj-&gt;id ." to user $MyUser" ); <br />
my ($status, $msg) = $self-&gt;TicketObj-&gt;SetOwner( $MyUser ); <br />
unless( $status ) {<br />
$RT::Logger-&gt;warning( "Impossible to assign the ticket to $MyUser: $msg" );<br />
return undef; <br />
} 1;<br />
<br />
And that's it. Now you can send an email to [mailto:hardware@yoursite.com hardware@yoursite.com] and a ticket will be automatically created in the queue hardware and assigned to Joe. Thanks Joe, now come fix my !@##$# mouse!<br />
<br />
And if you have more queues that you want to automatically set owners at, just add the pairs queue=&gt;owner to the %owners hash.<br />
<br />
== Assigning owner conditionally based on ticket creator ==<br />
<br />
Let's say you want to automatically set the owner, but only if you're looking for something specific in the ticket creator's email address. The example below is if you want to automatically assign tickets to "harry" if (a) they are sent from [mailto:anyone@domain1.com anyone@domain1.com] or [mailto:anyone@domain2.com anyone@domain2.com], and (b) to the "general" queue.<br />
<br />
Alternate Custom Action Cleanup Code:<br />
<br />
my $MyUser = "harry";<br />
my $QueueName = "general";<br />
my $Sender = "@(domain1|domain2)\.com";<br />
return 1 unless $self-&gt;TicketObj-&gt;QueueObj-&gt;Name eq $QueueName;<br />
my $Actor = $self-&gt;TransactionObj-&gt;Creator;<br />
return 1 if $Actor == $RT::SystemUser-&gt;id;<br />
return 1 unless $self-&gt;TicketObj-&gt;Owner == $RT::Nobody-&gt;id;<br />
return 1 unless $self-&gt;TransactionObj-&gt;CreatorObj-&gt;Name() =~ /$Sender/;<br />
$RT::Logger-&gt;info("Auto assigning ticket #". $self-&gt;TicketObj-&gt;id ." to user $MyUser" );<br />
my ($status, $msg) = $self-&gt;TicketObj-&gt;SetOwner( $MyUser );<br />
unless( $status ) {<br />
$RT::Logger-&gt;warning("Impossible to assign the ticket to $MyUser: $msg");<br />
return undef;<br />
}<br />
1;<br />
<br />
== Changelog ==<br />
<br />
20060501 Haim Dimer.<br />
<br />
20060506 Andrew Foster - added alternate custom action code for conditional requestor<br />
<br />
== Comments ==<br />
<br />
2006.01.05 [mailto:purp@acm.org purp@acm.org]: Seems like, with a little tweaking of how $[[MyUser]] is assigned, you could round-robin through the members of an RT group. I don't know how you'd preserve the state of who was last assigned, but that's the only hitch I see.<br />
<br />
2006.04.12 [mailto:jcolson@voidgate.org jcolson@voidgate.org]: How about querying the number of tickets assigned to each person in the group and assigning to the person with the least open.</div>
99.224.22.98