[rt-users] getting Custom Field Values for Users

Mathew Snyder theillien at yahoo.com
Thu May 10 04:54:36 EDT 2007


I'm trying to figure out how to get the value of a custom field for a user.  My
script goes through transactions and adds time up for each privileged user,
creates a HoHoH, manipulates the data and enters it into a file.  The file is
then emailed to a few people.  However, I would like to be able to add each user
to one of two hashes based on a user custom field, populate two files based on
the hashes and then email each to the appropriate person.

I don't know how to go about getting the custom field value for a creator of a
transaction, though.  I'm guessing I would have load the user object of the
creator and then use FirstCustomFieldValue on it, using the result of that to
determine which hash to place the user in.

Is this what it should look like?
<snip>
my $transactions = $ticket->Transactions;
        while (my $transaction  = $transactions->Next) {
		next unless ($transaction->TimeTaken);
                next unless $creator->Privileged;
                my $creator     = $transaction->CreatorObj;
                my $user        = new RT::User(RT::SystemUser);
                $user->Load('$creator');
                my $dept = $user->FirstCustomFieldValue('Department');
                if ($dept == 'Engineering') {
                        $eng{$env}{$creator->Name} += $transaction->TimeTaken;
                }elsif ($dept == 'Operations') {
                        $ops{$env}{$creator->Name} += $transaction->TimeTaken;
                }else{
                        next;
                }
        }
</snip>

-- 
Keep up with me and what I'm up to: http://theillien.blogspot.com



More information about the rt-users mailing list