[rt-users] Pulling CustomFieldValues

Garry T. Williams garry.williams at cbeyond.net
Mon Nov 27 10:00:53 EST 2006


On Thursday 23 November 2006 03:36, Mathew Snyder wrote:
> This is beginning to make my head hurt.  I assume by loading up a
> CustomField object you mean use the Load subroutine in
> CustomField_Overlay.pm.  There is a subroutine called Load that
> checks if an ID or Name is provided.  So would it be:
> my $cf_id = RT::CustomField->Load(Name => "Profiles");
> 
> This is confusing.

Yes, it is.  But it's not too bad, once you get used to the
conventions used in RT.

Create a new CustomField object:

    my $cf = RT::CustomField->new($session{CurrentUser});

Load it from a particular custom field (using its name):

    $cf->LoadByName(Name => $cf_name);

Now you can ask it to return its id value:

    my $cf_id = $cf->Id();

You also correctly found that the RT::CustomField object has a Load()
method that takes either the id (the thing we want, but don't have) or
a name.  But that method doesn't take a key value pair -- it just
takes the id or name.  So the above $cf->LoadByName(Name => $cf_name)
can be this instead:

    $cf->Load($cf_name);

The Load() method will load by name, if its parameter is not an
integer.

-- 
Garry T. Williams --- 678-370-2438




More information about the rt-users mailing list