[rt-users] Pulling CustomFieldValues

Mathew Snyder theillien at yahoo.com
Wed Nov 29 02:54:46 EST 2006


Wow, that did help.  That cleared up a lot of confusion for me.  Now I have the
following code:
#!/usr/bin/perl
use warnings;
use strict;
use lib "/usr/local/rt-3.6.1/lib";
use RT;
use RT::CustomField;
use RT::Interface::CLI qw(CleanEnv);

CleanEnv();
RT::LoadConfig();
RT::Init();
my $cf_name = "Profiles";

my $cf = RT::CustomField->new(RT::SystemUser);
$cf->Load($cf_name);

my $cfv;
while ($cfv = $cf->Next) {
    print $cfv->Name . "\n";
}

exit;

When I run this I get:
[Wed Nov 29 11:34:20 2006] [crit]: RT::CustomField::Next Unimplemented in main.
(./profiles.pl line 18)  (/usr/local/rt-3.6.1/lib/RT.pm:317)
RT::CustomField::Next Unimplemented in main. (./profiles.pl line 18)

How is it unimplemented if I'm using RT::CustomField?

Thanks,
Mathew

Garry T. Williams wrote:
> 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.
> 



More information about the rt-users mailing list