[rt-devel] Getting Custom Fields for a User

Lee Wilson leefm40 at yahoo.co.uk
Sun Apr 22 17:52:39 EDT 2012

On 22/04/2012 04:53, Ruslan Zakirov wrote:


> First of all every object has CustomFieldValues method that return the
> same thing. So after getting name of a CF you can call it on
> §session{CurrentUser}->UserObj.
> ObjectCustomFieldValues is just another collection you walk with Next
> and while loop. If you know for sure that all fields are single value
> then you can use FirstCustomFieldValue.

Excellent, thanks to your help think I've got there:

% while ( my $CustomField = $CustomFields->Next) {
<% loc($CustomField->Name) %>
% my $cfValues = 
$session{CurrentUser}->UserObj->FirstCustomFieldValue($CustomField->Name) %>
<br />
%  }
% }

The above code shows how I got the first value but also found I could 
get it with:


or through a loop (which may help with future tasks):

% while ( my $cfValue = $cfValues->Next) {
<%$cfValue->Content %>
% }

Your help is very much appreciated.  Now, to figure out how to do a add 
a hidden custom field :-~


More information about the rt-devel mailing list