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

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to