Subject: | "Select multiple" not handled properly |
Date: | Thu, 09 Feb 2012 14:21:28 -0500 |
To: | bug-RT-Extension-SearchResults-XLS [...] rt.cpan.org |
From: | Jeff Blaine <jblaine [...] kickflop.net> |
Custom field values with multiple possible values selected
display in the spreadsheet separated by <br/> tags because
you are not iterating over $values->Next like the native
RT code does.
To fix:
#...
#include this, copied straight from the RT Results.tsv code
#...
my %cf_id_to_name;
my %cf_name_to_pos;
{
my $cfs = RT::SQL::PossibleCustomFields(
Query => $Query, CurrentUser => $session{'CurrentUser'},
);
while ( my $cf = $cfs->Next ) {
my $name = $cf->Name;
$cf_id_to_name{ $cf->id } = $name;
next if $cf_name_to_pos{ $name };
$cf_name_to_pos{ $name } =
(sort { $b <=> $a } values %cf_name_to_pos)[0] + 1;
}
}
# ... your code here, with an addition below (find "ADD")
while ( my $Ticket = $Tickets->Next()) {
my @row;
foreach my $attr (@cols) {
push @row, ProcessColumnMapValue ($attr, Arguments => [
$Ticket, 0 ], Escape => 1);
}
# ADD: And do this loop to comma-separate values
my $values = $Ticket->CustomFieldValues;
$values->OrderByCols; # don't sort them
while (my $value = $values->Next) {
my $pos = $cf_name_to_pos{ $cf_id_to_name{ $value->CustomField
} };
next unless $pos;
$row[$pos] = '' unless defined $row[$pos];
$row[$pos] .= ', ' if $row[$pos];
$row[$pos] .= $value->Content;
}