[rt-users] getting Custom Field Values for Users
Mathew
theillien at yahoo.com
Sun May 13 08:11:27 EDT 2007
Nevermind, I figured out that I wasn't using the Name method on my
$creator object. Also, I needed to take the quotes from around
$creator-Name on the line containing $user->Load('$creator');
It is now $user->Load($creator->Name); which works exactly as I'd hoped.
Mathew Snyder wrote:
> I've stepped through this with the debugger and have found that the $dept
> variable isn't being populated. I've also double checked that the custom field
> has a value for each privileged user within RT so I know it shouldn't be blank
> all the time. I've also changed the '==' to 'eq' like it should be.
>
> Any thoughts?
>
> Mathew
> Keep up with me and what I'm up to: http://theillien.blogspot.com
>
>
> Gene LeDuc wrote:
>> 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
>>
> _______________________________________________
> 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
>
More information about the rt-users
mailing list