<?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=SelectDefaultQueue</id>
	<title>SelectDefaultQueue - 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=SelectDefaultQueue"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SelectDefaultQueue&amp;action=history"/>
	<updated>2026-08-22T10:02:10Z</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=SelectDefaultQueue&amp;diff=3430&amp;oldid=prev</id>
		<title>Admin: 3 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=SelectDefaultQueue&amp;diff=3430&amp;oldid=prev"/>
		<updated>2016-04-06T20:37:38Z</updated>

		<summary type="html">&lt;p&gt;3 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Instead of patching RT, this is easily done globally (or per user in preferences) using the [http://bestpractical.com/docs/rt/latest/RT_Config.html#DefaultQueue DefaultQueue config option] ===&lt;br /&gt;
=== ===&lt;br /&gt;
=== What This Is ===&lt;br /&gt;
&lt;br /&gt;
This patch, along with a user-based custom field named &amp;quot;Default Queue&amp;quot;, allows per-user specification of which queue is selected by default in queue name drop down lists. Additionally, it allows you to set [=[[DefaultQueueId]]] in [[RT SiteConfig|RT_SiteConfig]].pm to choose a default queue for users without a default queue setting.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;This includes the queue name drop down in the Search Page.&amp;#039;&amp;#039;&amp;#039; If you find that annoying, you&amp;#039;ll need to add an arg (e.g. [[NoUserDefQueue]]), then modify the &amp;lt;code&amp;gt;unless ($Default)&amp;lt;/code&amp;gt; conditional, and finally modify the Search/Build.html page to set your new arg properly.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; If you want to allow users to choose their own default queue, have a look at the [[DisplayCustomFieldsInUserPrefs]] contribution.&lt;br /&gt;
&lt;br /&gt;
The patch below was made against RT 3.5.5; I suspect the logic can be transplanted as far back as 3.2, though.&lt;br /&gt;
&lt;br /&gt;
=== How To Install This ===&lt;br /&gt;
&lt;br /&gt;
# Create a custom field named &amp;#039;Default Queue&amp;#039; which applies to Users; it should be a &amp;quot;Select one value&amp;quot; field whose values are &amp;#039;&amp;#039;&amp;#039;exactly&amp;#039;&amp;#039;&amp;#039; the same as your queue names in spelling, case, and whitespace, if any.&lt;br /&gt;
# Save the patch below in /tmp/[[SelectQueue]].patch&lt;br /&gt;
# mkdir /path/to/rt/local/html/Elements&lt;br /&gt;
# cd /path/to/rt/local/html/Elements&lt;br /&gt;
# cp /path/to/rt/share/html/Elements/[[SelectQueue]] .&lt;br /&gt;
# patch -p3 &amp;amp;lt; /tmp/[[SelectQueue]].patch&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Patch for RT 3.5.5&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;--- share/html/Elements/SelectQueue     2005-07-31 09:27:38.000000000 -0700&lt;br /&gt;
  +++ local/html/Elements/SelectQueue     2005-11-23 15:28:54.000000000 -0800&lt;br /&gt;
  @@ -52,9 +52,9 @@&lt;br /&gt;
   &amp;amp;lt;select name=&amp;quot;&amp;amp;lt;%$Name%&amp;amp;gt;&amp;quot;&amp;amp;gt;&lt;br /&gt;
   %     if ($ShowNullOption) {&lt;br /&gt;
     &amp;amp;lt;option value=&amp;quot;&amp;quot;&amp;amp;gt;-&amp;amp;lt;/option&amp;amp;gt;&lt;br /&gt;
   %     }&lt;br /&gt;
  -%     for my $queue (@{$cache{$cache_key}}) {&lt;br /&gt;
  +%     for my $queue (@{$cache{$queue_list_cache}}) {&lt;br /&gt;
     &amp;amp;lt;option value=&amp;quot;&amp;amp;lt;% ($NamedValues ? $queue-&amp;amp;gt;{Name} : $queue-&amp;amp;gt;{Id}) %&amp;amp;gt;&amp;quot; &amp;amp;lt;% ($queue-&amp;amp;gt;{Id} eq $Default ? &amp;#039;selected=&amp;quot;selected&amp;quot;&amp;#039; : &amp;#039;&amp;#039;) |n %&amp;amp;gt;&amp;amp;gt;&lt;br /&gt;
       &amp;amp;lt;%$queue-&amp;amp;gt;{Name}%&amp;amp;gt;&lt;br /&gt;
   %             if ($Verbose and $queue-&amp;amp;gt;{Description}) {&lt;br /&gt;
       (&amp;amp;lt;%$queue-&amp;amp;gt;{Description}%&amp;amp;gt;)&lt;br /&gt;
  @@ -65,8 +65,9 @@&lt;br /&gt;
   % }&lt;br /&gt;
   &amp;amp;lt;%once&amp;amp;gt;&lt;br /&gt;
   my %cache;&lt;br /&gt;
   &amp;amp;lt;/%once&amp;amp;gt;&lt;br /&gt;
  +&lt;br /&gt;
   &amp;amp;lt;%args&amp;amp;gt;&lt;br /&gt;
   $CheckQueueRight =&amp;amp;gt; &amp;#039;CreateTicket&amp;#039;&lt;br /&gt;
   $ShowNullOption =&amp;amp;gt; 1&lt;br /&gt;
   $ShowAllQueues =&amp;amp;gt; 1&lt;br /&gt;
  @@ -75,24 +76,43 @@&lt;br /&gt;
   $NamedValues =&amp;amp;gt; 0&lt;br /&gt;
   $Default =&amp;amp;gt; 0&lt;br /&gt;
   $Lite =&amp;amp;gt; 0&lt;br /&gt;
   &amp;amp;lt;/%args&amp;amp;gt;&lt;br /&gt;
  +&lt;br /&gt;
   &amp;amp;lt;%init&amp;amp;gt;&lt;br /&gt;
  -my $cache_key = &amp;quot;SelectQueue---&amp;quot;&lt;br /&gt;
  +my $queue_list_cache = &amp;quot;SelectQueue---&amp;quot;&lt;br /&gt;
                   . $session{&amp;#039;CurrentUser&amp;#039;}-&amp;amp;gt;Id&lt;br /&gt;
                   . &amp;quot;---$CheckQueueRight---$ShowAllQueues&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
  -if (not defined $cache{$cache_key} and not $Lite) {&lt;br /&gt;
  +if (not defined $cache{$queue_list_cache} and not $Lite) {&lt;br /&gt;
       my $q = new RT::Queues($session{&amp;#039;CurrentUser&amp;#039;});&lt;br /&gt;
       $q-&amp;amp;gt;UnLimit;&lt;br /&gt;
  &lt;br /&gt;
       while (my $queue = $q-&amp;amp;gt;Next) {&lt;br /&gt;
           if ($ShowAllQueues || $queue-&amp;amp;gt;CurrentUserHasRight($CheckQueueRight)) {&lt;br /&gt;
  -            push @{$cache{$cache_key}}, {&lt;br /&gt;
  +            push @{$cache{$queue_list_cache}}, {&lt;br /&gt;
                   Id          =&amp;amp;gt; $queue-&amp;amp;gt;Id,&lt;br /&gt;
                   Name        =&amp;amp;gt; $queue-&amp;amp;gt;Name,&lt;br /&gt;
                   Description =&amp;amp;gt; $queue-&amp;amp;gt;Description,&lt;br /&gt;
               };&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
  +&lt;br /&gt;
  +unless ($Default) {&lt;br /&gt;
  +  my $default_queue_cache = &amp;quot;SelectQueue---&amp;quot;&lt;br /&gt;
  +                . $session{&amp;#039;CurrentUser&amp;#039;}-&amp;amp;gt;Id&lt;br /&gt;
  +                . &amp;quot;---DefaultQueueId&amp;quot;;&lt;br /&gt;
  +  unless (defined($cache{$default_queue_cache})) {&lt;br /&gt;
  +    $cache{$default_queue_cache} = 0;&lt;br /&gt;
  +    my $sess_user = $session{&amp;#039;CurrentUser&amp;#039;};&lt;br /&gt;
  +    my $user = RT::User-&amp;amp;gt;new($sess_user);&lt;br /&gt;
  +    $user-&amp;amp;gt;Load($sess_user-&amp;amp;gt;Id);&lt;br /&gt;
  +&lt;br /&gt;
  +    my $def_queue = RT::Queue-&amp;amp;gt;new($sess_user);&lt;br /&gt;
  +    $def_queue-&amp;amp;gt;Load($user-&amp;amp;gt;CustomFieldValues(&amp;#039;Default Queue&amp;#039;)-&amp;amp;gt;First-&amp;amp;gt;Content) if $user-&amp;amp;gt;CustomFieldValues(&amp;#039;Default Queue&amp;#039;)-&amp;amp;gt;First;&lt;br /&gt;
  +    $cache{$default_queue_cache} = $def_queue-&amp;amp;gt;Id if $def_queue-&amp;amp;gt;Id;&lt;br /&gt;
  +  }&lt;br /&gt;
  +&lt;br /&gt;
  +  $Default = $cache{$default_queue_cache} || $RT::DefaultQueueId || 1;&lt;br /&gt;
  +}&lt;br /&gt;
   &amp;amp;lt;/%init&amp;amp;gt;&lt;br /&gt;
  &lt;br /&gt;
  &amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>