<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AutoSetOwnerForQueue</id>
	<title>AutoSetOwnerForQueue - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=AutoSetOwnerForQueue"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;action=history"/>
	<updated>2026-08-22T02:53:37Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=277&amp;oldid=prev</id>
		<title>Admin: 4 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=277&amp;oldid=prev"/>
		<updated>2016-04-06T20:03:18Z</updated>

		<summary type="html">&lt;p&gt;4 revisions imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:03, 6 April 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-276:rev-277 --&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=276&amp;oldid=prev</id>
		<title>66.63.81.145: The last line of the scrip was outside the code block.</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=276&amp;oldid=prev"/>
		<updated>2012-11-28T19:24:14Z</updated>

		<summary type="html">&lt;p&gt;The last line of the scrip was outside the code block.&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:24, 28 November 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l21&quot;&gt;Line 21:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 21:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return 1;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return 1;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;Custom Action Preparation:  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;Custom Action Preparation:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return 1;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return 1;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l38&quot;&gt;Line 38:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 38:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  unless( $status ) {&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  unless( $status ) {&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;        $RT::Logger-&amp;amp;gt;warning( &amp;quot;Impossible to assign the ticket to $MyUser: $msg&amp;quot; );&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;        $RT::Logger-&amp;amp;gt;warning( &amp;quot;Impossible to assign the ticket to $MyUser: $msg&amp;quot; );&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return undef;  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;  return undef;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;} 1;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;} 1;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;And that&amp;#039;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!&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;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;&quot;&gt;&lt;div&gt;And that&amp;#039;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!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key bestpractical_mediawiki1459887241:diff:1.41:old-275:rev-276:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>66.63.81.145</name></author>
	</entry>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=275&amp;oldid=prev</id>
		<title>99.224.22.98: Cleaned up Wiki formatting</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=AutoSetOwnerForQueue&amp;diff=275&amp;oldid=prev"/>
		<updated>2011-01-07T19:54:30Z</updated>

		<summary type="html">&lt;p&gt;Cleaned up Wiki formatting&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Say you want all the requests for new hardware to go to the queue &amp;quot;hardware&amp;quot; and be assigned to Joe the hardware guy. If so, this page is for you.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;The procedure involves 3 actions:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
1. Creating the queue &amp;quot;hardware&amp;quot;&lt;br /&gt;
&lt;br /&gt;
2. Adding the following email alias&lt;br /&gt;
&lt;br /&gt;
 hardware: |/usr/local/rt3/bin/rt-mailgate --queue hardware --action correspond --url http://rt.yoursite.com/&lt;br /&gt;
&lt;br /&gt;
3. Creating this Global scrip&lt;br /&gt;
&lt;br /&gt;
 Description: Assign Hardware Requests to Joe&lt;br /&gt;
 Condition: On Create&lt;br /&gt;
 Action: User Defined&lt;br /&gt;
 Template: Global Template: Blank&lt;br /&gt;
 Stage: TransactionCreate&lt;br /&gt;
&lt;br /&gt;
Custom Condition:&lt;br /&gt;
&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
Custom Action Preparation: &lt;br /&gt;
&lt;br /&gt;
 return 1;&lt;br /&gt;
&lt;br /&gt;
Custom Action Cleanup Code:&lt;br /&gt;
&lt;br /&gt;
 my %owners = ( &amp;#039;hardware&amp;#039; =&amp;amp;gt; &amp;#039;joe&amp;#039;,); &lt;br /&gt;
 my $QueueName = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;Name; &lt;br /&gt;
 return 1 unless defined($owners{$QueueName}); &lt;br /&gt;
 my $Actor = $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Creator; &lt;br /&gt;
 return 1 if $Actor == $RT::SystemUser-&amp;amp;gt;id; &lt;br /&gt;
 return 1 unless $self-&amp;amp;gt;TicketObj-&amp;amp;gt;Owner == $RT::Nobody-&amp;amp;gt;id; &lt;br /&gt;
 my $MyUser = $owners{$QueueName}; &lt;br /&gt;
 $RT::Logger-&amp;amp;gt;info(&amp;quot;Auto assigning ticket #&amp;quot;. $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id .&amp;quot; to user $MyUser&amp;quot; ); &lt;br /&gt;
 my ($status, $msg) = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetOwner( $MyUser ); &lt;br /&gt;
 unless( $status ) {&lt;br /&gt;
       $RT::Logger-&amp;amp;gt;warning( &amp;quot;Impossible to assign the ticket to $MyUser: $msg&amp;quot; );&lt;br /&gt;
 return undef; &lt;br /&gt;
} 1;&lt;br /&gt;
&lt;br /&gt;
And that&amp;#039;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!&lt;br /&gt;
&lt;br /&gt;
And if you have more queues that you want to automatically set owners at, just add the pairs queue=&amp;amp;gt;owner to the %owners hash.&lt;br /&gt;
&lt;br /&gt;
== Assigning owner conditionally based on ticket creator ==&lt;br /&gt;
&lt;br /&gt;
Let&amp;#039;s say you want to automatically set the owner, but only if you&amp;#039;re looking for something specific in the ticket creator&amp;#039;s email address. The example below is if you want to automatically assign tickets to &amp;quot;harry&amp;quot; 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 &amp;quot;general&amp;quot; queue.&lt;br /&gt;
&lt;br /&gt;
Alternate Custom Action Cleanup Code:&lt;br /&gt;
&lt;br /&gt;
 my $MyUser = &amp;quot;harry&amp;quot;;&lt;br /&gt;
 my $QueueName = &amp;quot;general&amp;quot;;&lt;br /&gt;
 my $Sender = &amp;quot;@(domain1|domain2)\.com&amp;quot;;&lt;br /&gt;
 return 1 unless $self-&amp;amp;gt;TicketObj-&amp;amp;gt;QueueObj-&amp;amp;gt;Name eq $QueueName;&lt;br /&gt;
 my $Actor = $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Creator;&lt;br /&gt;
 return 1 if $Actor == $RT::SystemUser-&amp;amp;gt;id;&lt;br /&gt;
 return 1 unless $self-&amp;amp;gt;TicketObj-&amp;amp;gt;Owner == $RT::Nobody-&amp;amp;gt;id;&lt;br /&gt;
 return 1 unless $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;CreatorObj-&amp;amp;gt;Name() =~ /$Sender/;&lt;br /&gt;
 $RT::Logger-&amp;amp;gt;info(&amp;quot;Auto assigning ticket #&amp;quot;. $self-&amp;amp;gt;TicketObj-&amp;amp;gt;id .&amp;quot; to user $MyUser&amp;quot; );&lt;br /&gt;
 my ($status, $msg) = $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetOwner( $MyUser );&lt;br /&gt;
 unless( $status ) {&lt;br /&gt;
   $RT::Logger-&amp;amp;gt;warning(&amp;quot;Impossible to assign the ticket to $MyUser: $msg&amp;quot;);&lt;br /&gt;
   return undef;&lt;br /&gt;
 }&lt;br /&gt;
 1;&lt;br /&gt;
&lt;br /&gt;
== Changelog ==&lt;br /&gt;
&lt;br /&gt;
20060501 Haim Dimer.&lt;br /&gt;
&lt;br /&gt;
20060506 Andrew Foster - added alternate custom action code for conditional requestor&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
&lt;br /&gt;
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&amp;#039;t know how you&amp;#039;d preserve the state of who was last assigned, but that&amp;#039;s the only hitch I see.&lt;br /&gt;
&lt;br /&gt;
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.&lt;/div&gt;</summary>
		<author><name>99.224.22.98</name></author>
	</entry>
</feed>