[Rt-devel] Problem with CF for Users

Kevin Falcone falcone at bestpractical.com
Tue Feb 8 11:40:59 EST 2011


On Tue, Feb 08, 2011 at 02:49:17PM +0100, Björn Schulz wrote:
> Hi all,
> 
> we've a problem with custom fields for users on rt 3.8.8.

It is worth noting that Tickets_Overlay.pm has a LimitCustomField but
Users is falling back to the generic code in RT::SearchBuilder.
I suggest a ->BuildSelectQuery to confirm what the sql is doing, but
if I had to guess, I'd suspect that Users isn't skipping disabled OCFV
records, which means that the old value for that user is found.

-kevin

> Here is my problem:
> 
> Step1
> We add a value to a user cf, lets say 'String1 = ABCDEFGH'
> 
> $UserObject->AddCustomFieldValue("Field" => $MStatusName, "Value" =>
> $String1,"RecordTransaction" => 0);
> 
> Step2
> Then we limit a user object to this cf value to find all users with this
> value in our user base.
> 
> $Users1->LimitCustomField("CUSTOMFIELD" => $MStatusId,
>                          "OPERATOR" => "=",
>                          "VALUE" => $String1 );
> 
> That works fine!
> 
> Step3 Error
> We change the value from 'ABCDEFGH' to 'RSTUVWXYZ'
> and limit the object to 'ABCDEFGH' the user with the new value is shown
> in the result.
> 
> With Ticket objects this works fine.
> 
> Any comments?
> 
> 
> Cheers,
>  Björn
> 
> 
> here is a little script that shows the problem:
> 
> #!/usr/bin/perl -w
> use strict;
> use lib "/opt/rt3/RTIM/lib",  "/opt/rt3/lib";
> use RT;
> RT::LoadConfig();
> RT::Init();
> use RT::Interface::CLI "GetCurrentUser", "loc";
> use RT::Users;
> 
> my $CurrentUser = GetCurrentUser();
> my $Users1 = new RT::Users($CurrentUser);
> my $Users2 = new RT::Users($CurrentUser);
> my $UserObject = RT::User->new($CurrentUser);
> my ($String1, $String2) = ("ABCDEFGH", "RSTUVWXYZ");
> # The customfield #126 is a user customfield whose name is
> # 'MergeStatus'
> my $MStatusId = 126;
> my $MStatusName = "MergeStatus";
> # The number has to be an id  of an existing user!
> $UserObject->Load(14788);
> # The customfield #126 of the user is being changed to 'ABCDEFGH'.
> $UserObject->AddCustomFieldValue("Field" => $MStatusName, "Value" =>
> $String1,"RecordTransaction" => 0);
> $Users1->LimitCustomField("CUSTOMFIELD" => $MStatusId,
>                          "OPERATOR" => "=",
>                          "VALUE" => $String1 );
> 
> print "Users with the Status $String1\n";
> 
> while (my $UC = $Users1->Next())
> {
>     my $MStatusValue;
>     my $CFValues = $UC->CustomFieldValues($MStatusId);
>     while (my $CFValue = $CFValues->Next)
>     {
>         $MStatusValue = $CFValue->Content;
>     }
>     print join("\t", ($UC->Id, $UC->Name, $UC->RealName, $MStatusValue
> )), "\n";
> }
> print "\n\n\n";
> 
> # The customfield #126 of the user is being changed to 'RSTUVWXYZ'.
> $UserObject->DeleteCustomFieldValue("Field" => $MStatusName, "Value" =>
> $String1,"RecordTransaction" => 0);
> $UserObject->AddCustomFieldValue("Field" => $MStatusName, "Value" =>
> $String2,"RecordTransaction" => 0);
> # $User2 refers to the updated collection
> $Users2->LimitCustomField("CUSTOMFIELD" => $MStatusId,
>                          "OPERATOR" => "=",
>                          "VALUE" => $String1 );
> #User still occurs, although he should not occur anymore!
> print "Users with the Status $String1\n";
> while (my $UC = $Users1->Next())
> {
>     my $MStatusValue;
>     my $CFValues = $UC->CustomFieldValues($MStatusId);
>     while (my $CFValue = $CFValues->Next)
>     {
>         $MStatusValue = $CFValue->Content;
>     }
>     print join("\t", ($UC->Id, $UC->Name, $UC->RealName, $MStatusValue
> )), "\n";
> }
> _______________________________________________
> List info: http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-devel/attachments/20110208/c5f15506/attachment.pgp>


More information about the rt-devel mailing list