[rt-users] getting Custom Field Values for Users
Gene LeDuc
gleduc at mail.sdsu.edu
Thu May 10 11:34:19 EDT 2007
I'm not a guru, but the scrip logic looks right to me. If it's not
working, try replacing your $dept "==" equality checks with "eq" for strings.
At 01:54 AM 5/10/2007, Mathew Snyder wrote:
>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
>_______________________________________________
>http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
>
>Community help: http://wiki.bestpractical.com
>Commercial support: sales at bestpractical.com
>
>
>Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
>Buy a copy at http://rtbook.bestpractical.com
--
Gene LeDuc, GSEC
Security Analyst
San Diego State University
More information about the rt-users
mailing list