<?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=ApproximateSeparateQueues</id>
	<title>ApproximateSeparateQueues - 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=ApproximateSeparateQueues"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=ApproximateSeparateQueues&amp;action=history"/>
	<updated>2026-08-22T20:38:02Z</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=ApproximateSeparateQueues&amp;diff=189&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=ApproximateSeparateQueues&amp;diff=189&amp;oldid=prev"/>
		<updated>2016-04-06T20:03:15Z</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;= Using LDAP and custom fields to approximate separate queues =&lt;br /&gt;
&lt;br /&gt;
We use Request Tracker in our school system across eight separate elementary and secondary schools. All tickets feed into a single &amp;quot;Incidents&amp;quot; queue, but each building has its own technician, and I want RT to notify the building tech when a staff member from that building submits a ticket. The process proceeds in two distinct steps:&lt;br /&gt;
&lt;br /&gt;
# Query our LDAP server to set a ticket custom field that identifies the requestor&amp;#039;s school&lt;br /&gt;
# Based on the value of that custom field, notify the tech (or techs) at that school.&lt;br /&gt;
&lt;br /&gt;
== Step 1: Set the custom field ==&lt;br /&gt;
&lt;br /&gt;
I created a new scrip called &amp;quot;Set Building CF from LDAP&amp;quot; with the following settings:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Condition:&amp;#039;&amp;#039;&amp;#039; On Create&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Action:&amp;#039;&amp;#039;&amp;#039; User Defined&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Template:&amp;#039;&amp;#039;&amp;#039; Global template: Blank&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Custom action preparation code:&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;return 1;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Custom action cleanup code:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;my $mail = ($self-&amp;amp;gt;TicketObj-&amp;amp;gt;RequestorAddresses)[0];&lt;br /&gt;
 my $ldap = Net::LDAP-&amp;amp;gt;new( &amp;#039;10.1.10.230&amp;#039; );&lt;br /&gt;
 $ldap-&amp;amp;gt;bind;&lt;br /&gt;
 &lt;br /&gt;
 # Do the LDAP search. Note: Our eDirectory server uses &amp;quot;mail&amp;quot; for the&lt;br /&gt;
 # user&amp;#039;s email address.&lt;br /&gt;
 my $msg = $ldap-&amp;amp;gt;search( base   =&amp;amp;gt; &amp;#039;ou=Staff,o=Example&amp;#039;,&lt;br /&gt;
                          filter =&amp;amp;gt; &amp;quot;(mail=$mail)&amp;quot;,&lt;br /&gt;
                        );&lt;br /&gt;
 my $entry = $msg-&amp;amp;gt;entry(0);&lt;br /&gt;
 # Each user is a member of an ou which corresponds to his or her school&lt;br /&gt;
 my $ou = $entry-&amp;amp;gt;get_value(&amp;#039;ou&amp;#039;);&lt;br /&gt;
 &lt;br /&gt;
 # The value of the ou isn&amp;#039;t what I want to put in the custom field so&lt;br /&gt;
 # map the ou value to the corresponding custom field value.&lt;br /&gt;
 my %building_for = (&lt;br /&gt;
     &amp;#039;DISTRICT SERVICES&amp;#039; =&amp;amp;gt; &amp;#039;DO&amp;#039;,&lt;br /&gt;
     &amp;#039;HIGH SCHOOL&amp;#039;       =&amp;amp;gt; &amp;#039;BHS&amp;#039;,&lt;br /&gt;
     &amp;#039;MIDDLE SCHOOL&amp;#039;     =&amp;amp;gt; &amp;#039;BCMS&amp;#039;,&lt;br /&gt;
     &amp;#039;LINCOLN&amp;#039;           =&amp;amp;gt; &amp;#039;LES&amp;#039;,&lt;br /&gt;
     &amp;#039;_DEFAULT_&amp;#039;         =&amp;amp;gt; &amp;#039;DO&amp;#039;,&lt;br /&gt;
 );&lt;br /&gt;
 my $building = $building_for{$ou} || $building_for{_DEFAULT_};&lt;br /&gt;
 &lt;br /&gt;
 my $cf = RT::CustomField-&amp;amp;gt;new( $RT::SystemUser );&lt;br /&gt;
 $cf-&amp;amp;gt;LoadByName( Name =&amp;amp;gt; &amp;#039;Building&amp;#039; );&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;AddCustomFieldValue( Field =&amp;amp;gt; $cf, Value =&amp;amp;gt; $building );&lt;br /&gt;
 &lt;br /&gt;
 return 1;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this scrip in place, every incoming ticket has its &amp;quot;Building&amp;quot; custom field set to the requestor&amp;#039;s school.&lt;br /&gt;
&lt;br /&gt;
== Step 2: Notify the building tech ==&lt;br /&gt;
&lt;br /&gt;
I created a second scrip to trigger whenever the &amp;quot;Building&amp;quot; custom field is changed. It has these settings:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Description:&amp;#039;&amp;#039;&amp;#039; Notify techs of new tickets&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Condition:&amp;#039;&amp;#039;&amp;#039; User Defined&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Action:&amp;#039;&amp;#039;&amp;#039; Notify Other Recipients&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Template:&amp;#039;&amp;#039;&amp;#039; Building Tech Notify&lt;br /&gt;
&lt;br /&gt;
The custom condition code looks like this:&lt;br /&gt;
&lt;br /&gt;
 unless (&lt;br /&gt;
  ( $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Type eq &amp;quot;CustomField&amp;quot;&lt;br /&gt;
    &amp;amp;amp;&amp;amp;amp;  $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Field == 10 )&lt;br /&gt;
  ||  $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Type eq &amp;quot;Create&amp;quot;&lt;br /&gt;
  ) {&lt;br /&gt;
    return 0;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 1;&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
More information about triggering scrips on custom field changes can be found at the [[CustomConditionSnippets#Checks_with_Custom_Fields]] page of the wiki.&lt;br /&gt;
&lt;br /&gt;
In order to notify the proper tech that a new ticket has been created, I created an RT group for each building. The group names are of the form &amp;quot;SupportTeam-X&amp;quot; where X is the building code found in the &amp;quot;Building&amp;quot; custom field of each ticket. With this approach I can notify more than one tech at a building by making sure each tech is a member of his or her building group. The code to examine the group members is in the following &amp;quot;Building Tech Notify&amp;quot; template.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;To: { my $bldg = $Ticket-&amp;amp;gt;FirstCustomFieldValue(&amp;#039;Building&amp;#039;);&lt;br /&gt;
       my $group = RT::Group-&amp;amp;gt;new( $RT::SystemUser );&lt;br /&gt;
       $group-&amp;amp;gt;LoadUserDefinedGroup(&amp;quot;SupportTeam-$bldg&amp;quot;);&lt;br /&gt;
       $group-&amp;amp;gt;MemberEmailAddressesAsString; }&lt;br /&gt;
 Subject: Notify: {$Ticket-&amp;amp;gt;Subject}&lt;br /&gt;
 &lt;br /&gt;
 Greetings,&lt;br /&gt;
 &lt;br /&gt;
 A new ticket has been created, and it looks like it&amp;#039;s from {&lt;br /&gt;
   my $users = $Ticket-&amp;amp;gt;Requestors-&amp;amp;gt;UserMembersObj;&lt;br /&gt;
   my $output = &amp;#039;&amp;#039;;&lt;br /&gt;
   while( my $user = $users-&amp;amp;gt;Next ) {&lt;br /&gt;
      $output .= &amp;#039;, &amp;#039; if $output;&lt;br /&gt;
      $output .= $user-&amp;amp;gt;RealName; # or any other user&amp;#039;s property&lt;br /&gt;
   }&lt;br /&gt;
   $output;&lt;br /&gt;
 } at {$Ticket-&amp;amp;gt;FirstCustomFieldValue(&amp;#039;Building&amp;#039;)}. Here&amp;#039;s the original message:&lt;br /&gt;
 &lt;br /&gt;
 --snip--&lt;br /&gt;
 {$Ticket-&amp;amp;gt;Transactions-&amp;amp;gt;First-&amp;amp;gt;Content()}&lt;br /&gt;
 --snip--&lt;br /&gt;
 &lt;br /&gt;
 If you&amp;#039;re ready to start working on this ticket, you can do so at the following URL or by responding to the requestor directly by replying to this message:&lt;br /&gt;
 &lt;br /&gt;
 { $RT::WebURL }Ticket/Display.html?id={ $Ticket-&amp;amp;gt;Id() }&lt;br /&gt;
 &lt;br /&gt;
 -RT&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Besides notifying the building tech, this template also prints the name of the requestor in the body of the message.&lt;br /&gt;
&lt;br /&gt;
This approach has worked well for us. We could have created separate RT queues for each building, but this approach achieves a similar degree of separation while enabling the building techs to collaborate on tickets more conveniently. Each tech has created a custom &amp;quot;RT at a glance&amp;quot; page which utilizes a saved search to display the newest tickets from their school.&lt;br /&gt;
&lt;br /&gt;
== Acknowledgements ==&lt;br /&gt;
&lt;br /&gt;
Thanks to Keith Schincke, Ruslan Zakirov, Gene LeDuc, Robert Long, David Narayan, and Kenneth Crocker for providing timely advice on the RT-users mailing list.&lt;br /&gt;
&lt;br /&gt;
Submitted by [[TimWilson]]. Feel free to send me a message via the RT-users mailing list if you have any questions.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Active Directory ==&lt;br /&gt;
&lt;br /&gt;
Edit By David Kirk&lt;br /&gt;
&lt;br /&gt;
When using this with Active Directory, I had to do the following to make it work:&lt;br /&gt;
&lt;br /&gt;
while( my $entry = $msg-&amp;amp;gt;shift_entry) {&lt;br /&gt;
&lt;br /&gt;
my $dn = $entry-&amp;amp;gt;dn;&lt;br /&gt;
&lt;br /&gt;
my $ounum=0;&lt;br /&gt;
&lt;br /&gt;
my $[[SecondOU]];&lt;br /&gt;
&lt;br /&gt;
foreach my $dnparts(split (&amp;#039;,&amp;#039;,$dn)) {&lt;br /&gt;
&lt;br /&gt;
 my %attributes=split(&amp;#039;=&amp;#039;,$dnparts);&lt;br /&gt;
 if (defined $attributes{&amp;quot;OU&amp;quot;}) {&lt;br /&gt;
 $ounum++;}&lt;br /&gt;
 if ($ounum==2){&lt;br /&gt;
 $SecondOU=$attributes{&amp;quot;OU&amp;quot;};&lt;br /&gt;
 $ounum++;}&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
I use the second OU up from the user to determine what queue it is assigned to.&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>