[rt-users] Retrieve CF names by Queue

Andy Harrison ah30 at harrisonfamily.com
Mon Mar 1 11:59:13 EST 2004


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On Mon, 1 Mar 2004 09:20:59 -0500, Russ Roff wrote
Subject: "[rt-users] Retrieve CF names by Queue"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> Could anyone give me a hint with some perl code with how to retrieve a list of all CFs for a particular queue?
> 
> Thanks.
> 
> Russ


Here's a little snippet of one of my scripts that is mostly Ruslan's
doing.

% my $CFs = $QueueObj->CustomFields($ARGS{'CustomField'});


% while (my $CF = $CFs->Next) {
%  my $CFVs = $CF->Values();
%  while ( my $CFV = $CFVs->Next ) {
%    next unless $CFV->CustomField == $ARGS{'CustomField'};
          <tr>
            <td class="right"><% $CFV->Name %> </td>
            <td class="left"><% $CFV->Description %> </td>
          </tr>
%  }
% }

<%INIT>
use Data::Dumper;
$Data::Dumper::Indent=1;
use RT::Users;
use RT::Group;
use RT::Principal;
my $GroupObj = new RT::Group($session{'CurrentUser'});
my $UserObj = new RT::Users($session{'CurrentUser'});
my $QueueObj = new RT::Queue($session{'CurrentUser'});
##my $PrincipalObj = $GroupObj->PrincipalId($QueueObj);
#my $PrincipalObj = $GroupObj->PrincipalObj($session{'CurrentUser'});
$QueueObj->Load($Queue) || Abort (loc("Queue could not be loaded."));

</%INIT>

<%ARGS>
$Queue  => 35
$CF     => undef
$CFV    => undef
</%ARGS>


In this case, I pass the custom field id to this script.  Obviously
you wont need to include each and every line in the init block.

-- 
Andy Harrison
(full headers for details)



More information about the rt-users mailing list