User Custom Fields not being displayed?

Anyone else using User Custom Fields?

I was trying to get them to work in a 3.8.6 instance, but they do not
appear in the User’s CustomFields box.

I took a look at what Admin/Users/Modify.html is doing to display the
fields and noticed that it is trying to list the fields of the
CurrentUser, rather than looping through all fields available for
users. I modified this code as shown below and now I can see the
custom fields, but I’m running into errors when I set them from the
UI. I set one of these fields from the backend and had it populate
the selected item properly, so I know I’m getting close. I just
figured I’d ping to see if anyone else has run into this. I didn’t
see any changes in 3.8.8 relevant to this code.

The error that I’m getting on updates is:

Custom field RT::CustomField=HASH(0x7f0835dfcc88) does not apply to this object

— Modify.html~ 2009-11-20 14:19:31.000000000 -0500
+++ Modify.html 2010-05-28 13:37:19.282276082 -0400
@@ -208,7 +208,9 @@


<&| /Widgets/TitleBox, title => loc(‘Custom Fields’) &>

-% my $CFs = $UserObj->CustomFields; +% my $CFs = new RT::CustomFields($session{'CurrentUser'}); +% $CFs->LimitToLookupType( 'RT::User' ); +%# $UserObj->CustomFields; % while (my $CF = $CFs->Next) {
<% loc($CF->Name) %>:

Anyone else using User Custom Fields?

I was trying to get them to work in a 3.8.6 instance, but they do not
appear in the User’s CustomFields box.

I took a look at what Admin/Users/Modify.html is doing to display the
fields and noticed that it is trying to list the fields of the
CurrentUser, rather than looping through all fields available for
users.

a) Why do you think $UserObj is the CurrentUser?
b) Have you gone to Configuration → Global → Custom Fields → Users
and applied your custom fields?

-kevin

Kevin –

Thank you. Indeed I had overlooked applying it at a Global level.
The lack of an “Applies to” button on the User Custom field led me to
think it was only a global option and automatically applied.

Now for the challenge question. Is there any way to utilize the
user’s attributes and customfieldvalues in a search?

I’m attempting to create standardized dashboards for a good number of
teams/queues, and to do so, it would be convenient to template the
searches using fields I’ve added. For example HomeQueue is one of
the custom fields, and I would like to be able to craft saved searches
for the generic dashboard something along the lines of:

Queue = ‘UserCF.{HomeQueue}’ AND ( Status = ‘new’ OR Status = ‘open’
OR Status = ‘stalled’ )

I know CurrentUser is one value handled specially for the “Tickets
I Own” saved searches, but I don’t see that this functionality is more
Generic…

BrianOn Fri, May 28, 2010 at 2:02 PM, Kevin Falcone falcone@bestpractical.com wrote:

a) Why do you think $UserObj is the CurrentUser?
b) Have you gone to Configuration → Global → Custom Fields → Users
and applied your custom fields?

-kevin

Here’s one way to add this functionality I proposed…

— /usr/local/p/rt-3.8.8/src/lib/RT/Tickets_Overlay_SQL.pm
2010-05-05 16:09:21.000000000 -0400
+++ Tickets_Overlay_SQL.pm 2010-05-28 16:09:08.892400954 -0400
@@ -201,6 +201,8 @@
# replace CurrentUser with id
$value = $self->CurrentUser->id if $value eq ‘CurrentUser’;

  •   $value = $self->CurrentUser->UserObj->FirstCustomFieldValue($1)
    
  •       if ($value =~ '__CurrentUserCF\.{(.+)}__');
    
       unless( $dispatch{ $class } ) {
           die "No dispatch method for class '$class'"
    

Cheers,
BrianOn Fri, May 28, 2010 at 2:45 PM, Brian D bjd-dev@simplicity.net wrote:

Kevin –

Thank you. Indeed I had overlooked applying it at a Global level.
The lack of an “Applies to” button on the User Custom field led me to
think it was only a global option and automatically applied.

Now for the challenge question. Is there any way to utilize the
user’s attributes and customfieldvalues in a search?

I’m attempting to create standardized dashboards for a good number of
teams/queues, and to do so, it would be convenient to template the
searches using fields I’ve added. For example HomeQueue is one of
the custom fields, and I would like to be able to craft saved searches
for the generic dashboard something along the lines of:

Queue = ‘UserCF.{HomeQueue}’ AND ( Status = ‘new’ OR Status = ‘open’
OR Status = ‘stalled’ )

I know CurrentUser is one value handled specially for the “Tickets
I Own” saved searches, but I don’t see that this functionality is more
Generic…

Brian

On Fri, May 28, 2010 at 2:02 PM, Kevin Falcone falcone@bestpractical.com wrote:

a) Why do you think $UserObj is the CurrentUser?
b) Have you gone to Configuration → Global → Custom Fields → Users
and applied your custom fields?

-kevin