[rt-users] [patch 3.8.1] simple search on custom fields

Jerrad Pierce jpierce at cambridgeenergyalliance.org
Mon Sep 8 13:00:18 EDT 2008


The simple patch below allows you to search on custom fields with the
syntax .fieldName:value.
The : is chosen to match fulltext, although a delimiting = may be
clearer for your users. This was
done so that I could add a "Tags" custom field to queues for free from
annotation & searching
of tickets with relationships that cannot be represented with links
(but perhaps queues, at the
expense of manageability)

--- /tmp/Googleish.pm   2008-09-08 12:37:19.000000000 -0400
+++ lib/RT/Search/Googleish.pm  2008-09-08 12:44:21.000000000 -0400
@@ -141,6 +141,10 @@
             push @owner_clauses, "Owner = '" . $User->Name . "'";
         }

+        elsif ( $key =~ /.(\w+):(\w+)/ ) {
+            push @user_clauses, "CF.{$1} LIKE '$2'";
+        }
+
         # Else, subject must contain $key
         else {
             $key =~ s/['\\].*//g;
[

An earlier incarnation matched /cf.(\w+):(\w+)/i but this seemed
unnecessarily verbose.

The text above has been added to the wiki as SearchCustomField
-- 
Cambridge Energy Alliance: Save money & the planet



More information about the rt-users mailing list