[rt-devel] Getting Custom Fields for a User

Lee Wilson leefm40 at yahoo.co.uk
Sat Apr 21 17:30:47 EDT 2012


On 16/04/2012 22:15, Ruslan Zakirov wrote:
> On Mon, Apr 16, 2012 at 23:29, Lee Wilson<leefm40 at yahoo.co.uk>  wrote:
>> Hi Ruslan,
>>
>> Thanks for that. Looking at the perldoc for User.pm doesn't give any mention
>> of that but I guess it's inherited from Record.pm
>
> Right. In theory CFs can be on any object in the system, so methods
> are in Record.pm.
>

<snip>

Thanks for the detailed reply Ruslan it's really helped me understand 
things.  In the meantime I've read about the RT:SystemUSer which may do 
things more like I want to as all I need to be able to do is get the 
values for the users custom fields when creating/editing a ticket.

I'm now a bit stuck on how to retrieve the values for the custom fields. 
Perhaps if I explain more what I'm trying to do someone be so kind as to 
explain the bit i've missed/got wrong:

1) Requestor creates a ticket
2) Upon the new ticket window loading, lookup the Account ID stored in 
the users custom field
3) Based on the Account ID display a list of services (stored in a 
seperate database/CRM) in a dropdown <-- got this bit working 
independently just not with RT.
4) Store the id of the selected service into a hidden ticket custom field.

I've got a few more processes that I wish to get working but the basic 
process is the same.

So far I've got as far as coding the following test routine is 
MassageCustomFields but can't get it to show the values of the 
associated current user:

% if ($CustomFields->First) {
Ok we've found some custom fields:<br />
% $CustomFields->GotoFirstItem;

<% $session{'CurrentUser'}->id %><br /> <-------- This Id displays fine
% while ( my $CustomField = $CustomFields->Next) {
<% loc($CustomField->Name) %> <------ Name of the custom field shows up
% $CustomField->Load($CustomField->Name);
<% $CustomField->ValuesForObject($session{'CurrentUser'}) %>
<br />
% }
% }


On the last line it returns a reference to 'RT::ObjectCustomFieldValues' 
but I can't figure out how to get the currently selected/filled in value.

Once again, thanks for all your help so far.

Lee


More information about the rt-devel mailing list