> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Mathew Snyder > Sent: Wednesday, November 22, 2006 3:35 AM > To: [email protected] > Subject: [rt-users] Pulling CustomFieldValues > > I'm trying to pull together a script which will print out all > the values from a > particular CF. It will work in conjunction with a bit of > code already provided > to me by Roy El-Hames. > > I think I've figured out that I need to use > RT::CustomFieldValues in order to > make use of the LimitToCustomField subroutine. What I can't > figure out is how > to pass the name of the CF to the subroutine. Being a perl > novice this eludes me. > > This is what I have so far: > > #!/usr/bin/perl > use lib "/usr/local/rt-3.6.1/lib"; > use RT; > use RT::Users ; ## you may not need this but what the he > use RT::CustomFieldValues; > use RT::Interface::CLI qw(CleanEnv); > use warnings; > > CleanEnv(); ##Cleaning the env > RT::LoadConfig(); ## Loading RT config > RT::Init(); ## Initialise RT > > my $users = new RT::Users(RT::SystemUser); > $users->LimitToPrivileged; > my $CustomField = new RT::CustomFieldValues(Profiles); > $CustomField->LimitToCustomField; > > while ( $user = $users->Next) { > next if $user->Name eq "root"; > print $user->Name . "\n"; > } > exit; > > Can someone help me out and point me in the right direction? > > Thanks, > Mathew >
Mathew, You can get at the values by using the LimitToCustomField method on a CustomFieldValues object, but you need to supply the custom field's Id as an argument: $CustomField->LimitToCustomField (VALUE => $cf_id); assuming you've got the CF id in $cf_id. So first you'd have to load up a CustomField object and get the Id from there. Incidentally, it might be misleading to call the CustomFieldValues object $CustomField. Another approach is to load the CustomField object and use the object's Values() method. This returns a CustomFieldValues object which you can then iterate through to see the CustomFieldValue objects. Steve _______________________________________________ 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
