Try using $cfval->Content instead of $cfval->Name, this seems to work for me.
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:rt-users- > [EMAIL PROTECTED] On Behalf Of Mathew Snyder > Sent: Thursday, December 07, 2006 02:54 > To: [EMAIL PROTECTED] > Cc: [email protected] > Subject: Re: [rt-users] Pulling CustomFieldValues > > Stephen Turner wrote: > > > > > >> -----Original Message----- > >> From: Mathew Snyder [mailto:[EMAIL PROTECTED] > >> Sent: Wednesday, November 29, 2006 4:29 AM > >> To: [EMAIL PROTECTED] > >> Cc: [email protected] > >> Subject: Re: [rt-users] Pulling CustomFieldValues > >> > >> Steve, > >> > >> This is the code I now have: > >> > >> my $cf = RT::CustomField->new(RT::SystemUser); > >> $cf->Values($cf_name); > >> foreach my $cf_key (${cf}){ > >> print $$cf_key{"KEY"} . "\n"; > >> }; > >> > >> Values() appears to return a reference to a hash. If I run > >> this code I get one > >> blank line back. I guess I don't know how to iterate through > >> the hash to print > >> out each item. How would I go about that? > >> > >> Mathew > >> > > > > Hi Mathew, > > > > You're getting close! The Values method actually returns a > CustomFieldValues > > object, even though a print will show a hash. This object represents > a > > collection of CustomFieldValue objects and you can iterate through > the value > > objects using the RT collections API (see RTx::SearchBuilder): > > > > My $cfvalues = $cf->Values($cf_name); > > while (my $cfval = $cfvalues->Next() ){ > > print $cfval->Name . "\n"; > > }; > > > > You can see this in action on the custom field 'modify' screen - ( > > /Admin/CustomFields/Modify.html ). This calls > > /Admin/Elements/EditCustomFieldValues which displays a list of the > existing > > values for the CF. > > > > Steve > > > > > > I guess it's time to revisit this after taking a break for a bit. > > The code I now have, based on the above is thus: > !/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); > my $cfvalues = $cf->Values($cf_name); > while (my $cfval = $cfvalues->Next() ){ > print $cfval->Name . "\n"; > }; > > exit; > > This will run and place me right back at the prompt without any output. > I guess > I just don't understand how to get the values of the custom field. > > Mathew > _______________________________________________ > 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 _______________________________________________ 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
