Hi.
I have created a modification of this script that groups and summarizes the
time by a custom field (named Customer). I have attached the modified script.
/Johan
-Original Message-
From: rt-users-boun...@lists.bestpractical.com [mailto:rt-users-
boun...@lists.bestpractical.com] On Behalf Of Johnny.five
Sent: den 29 december 2011 16:09
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Limiting by custom field on Time Worked report
Hello!
I'm trying to figure out how to get a custom field onto the Time Worked
report here:
http://requesttracker.wikia.com/wiki/TimeWorked
The idea is to allow filtering of results by a custom field in a ticket.
I've been trying to wrap my head around the processes/syntax or RT for
hours
- any guru out there willing to share some knowledge?
~John
--
View this message in context: http://old.nabble.com/Limiting-by-custom-
field-on-Time-Worked-report-tp33050563p33050563.html
Sent from the Request Tracker - User mailing list archive at Nabble.com.
RT Training Sessions (http://bestpractical.com/services/training.html)
* Boston March 5 6, 2012
<%args>
$startdate => undef
$enddate => undef
$queues=> undef
<& /Elements/Header, Title => $title &>
<& /Tools/Reports/Elements/Tabs, current_tab => 'Tools/Reports/TimeWorkedCustomer.html', Title => $title &>
<%init>
my ($start_date, $end_date, $effective_end_date, $title);
$title = loc('Time worked report');
$start_date = RT::Date->new($session{'CurrentUser'});
$end_date = RT::Date->new($session{'CurrentUser'});
# If we have a value for start date, parse it into an RT::Date object
if ($startdate) {
$start_date->Set(Format => 'unknown', Value => $startdate);
# And then get it back as an ISO string for display purposes, in the form field and
# report header
$startdate = $start_date->AsString(Format => 'ISO', Timezone => 'server');
}
# Same treatment for end date
if ($enddate) {
$end_date->Set(Format => 'unknown', Value => $enddate);
$enddate = $end_date->AsString(Format => 'ISO', Timezone => 'server');
}
<&|/l&>Start date:
<& /Elements/SelectDate, Name => 'startdate', Default => ($startdate) ? $start_date->AsString(Format => 'ISO', Timezone => 'server') : ''&>
(report will start from midnight on this day unless you indicate otherwise)
<&|/l&>End date:
<& /Elements/SelectDate, Name => 'enddate', Default => ($enddate) ? $end_date->AsString(Format => 'ISO', Timezone => 'server') : ''&>
(report will -not- be inclusive of this day unless you change the time from midnight)
<&|/l&>Queues:
<& /Elements/SelectMultiQueue, Name => 'queues', Default => ($queues) ? $queues : ''&>
<& /Elements/Submit&>
<%perl>
# TimeWorkedReport
# Version 0.04 2009-09-28
#
# Fran Fabrizio, UAB CIS, f...@cis.uab.edu
use strict;
# if we are just getting here and the form values are empty, we are done
if (!$startdate || !$enddate) {
return;
}
# get the queue object(s)
my $queuesobj = new RT::Queues($session{CurrentUser});
my ($queuelist, %queuesofinterest);
# The user's choice of queues will come in from the web form in the $queues variable, which is
# mapped to the SELECT field on the web interface for the report. Unfortunately, if the user
# chooses just one queue, $queues will have a scalar value, but if the user chooses multiple
# queues, it will be an arrayref. So we need to check for each case and process differently.
#
# What we want to construct is the %queuesofinterest simple lookup hash which defines a key
# that is the queue ID for each queue selected, and the $queuelist string, which is just for
# displaying the list of queues in the report header
if (ref $queues) {
# multiple queues selected
for (@$queues) {
$queuesobj->Limit(FIELD => "Id", OPERATOR => "=", VALUE => $_, ENTRYAGGREGATOR => "OR");
$queuesofinterest{$_} = 1;
}
$queuelist = join ", ", map {$_->Name} @{$queuesobj->ItemsArrayRef};
} else {
my $queue = new RT::Queue;
$queue->Load(Id => $queues);
$queuesofinterest{$queues} = 1;
$queuelist = $queue->Name;
}
# hash to hold statistics
# %stats will be a multilevel hash - first level keys are the usernames, second level keys are
# the ticket IDs, and for each ticket, we store an anonymous hash with keys Subject and TimeWorked
# (this implies that a single ticket can live under two+ users if they both worked the ticket)
my %stats;
# Get a new transactions object to hold transaction search results for this ticket
my $trans = new RT::Transactions($session{'CurrentUser'});
# only