[Rt-devel] A different customfield search bug

Ben Goodwin ben at atomicmatrix.net
Tue Feb 14 08:25:45 EST 2006

I've been following the SVN repo for some time now and a few weeks ago a 
user of mine reported she was unable to search data in a custom field.  
Indeed, (global) customfield searching is completely broken (I just svn 
update'd and it's still broken).  The attached code.txt returns no rows, 
though I guarantee there are thousands of matches.  The resulting MySQL 
query is attached as well.

It's looking like the  (ObjectCustomFields_1.ObjectId = main.Queue) is 
problematic for global custom fields as the ObjectId is 0 in this case.  
Indeed, if I search for data in a customfield that's attached to a 
specific queue, it works well.


    -=| Ben

-------------- next part --------------
SELECT DISTINCT main.* FROM (((Tickets main  LEFT JOIN ObjectCustomFields ObjectCustomFields_1  ON ( ObjectCustomFields_1.ObjectId = main.Queue))  LEFT JOIN CustomFields CustomFields_2  ON ( CustomFields_2.id = ObjectCustomFields_1.CustomField))  LEFT JOIN ObjectCustomFieldValues ObjectCustomFieldValues_3  ON ((ObjectCustomFieldValues_3.ObjectId = main.id)) AND(  ObjectCustomFieldValues_3.CustomField = CustomFields_2.id) AND( (ObjectCustomFieldValues_3.Disabled = '0')) AND( (ObjectCustomFieldValues_3.ObjectType = 'RT::Ticket')))   WHERE ((CustomFields_2.name = 'Customer')) AND ((main.EffectiveId = main.id)) AND ((main.Status != 'deleted')) AND ((main.Type = 'ticket')) AND ( ( (ObjectCustomFieldValues_3.Content = 'PHS') ) )
-------------- next part --------------
my $tickets = new RT::Tickets($RT::SystemUser);
$tickets->FromSQL ( q[CF.{Customer} = "PHS"] );

while (my $Ticket = $tickets->Next) {
        print $Ticket->id . " " . $Ticket->Subject . "\n";

More information about the Rt-devel mailing list