I have written an import page for some data.
It works well, it does it's work but, when I display the result page, does not dowload the error file.
When it downloads the error file, then does not show the result page.
I attach the codes,
This shows the result page, but does not download the attachment:
Code: Select all
my $Output = $Self->{LayoutObject}->Header();
$Output .= $Self->{LayoutObject}->NavigationBar();
# output import results
$Output .= $Self->{LayoutObject}->Block(
Name => 'ImportResult',
Data => {
FileName => $SourceFile{Filename} ||= '',
Deleted => $Deleted,
ReadToWrite => $ReadToWrite,
WriteToRead => $WriteToRead,
NewRead => $NewRead,
NewWrite => $NewWrite,
Error => $Error,
NotModified => $NotModified,
NotFound => $NotFound,
LinesProcessed => $line,
LinesSuccseeded => $linesSucceeded,
},
);
$Output .= $Self->{LayoutObject}->Output( TemplateFile => 'AgentITSMConfigItemGroupImport', Data => \%Param );
# If errors occured export them
if ($linesSucceeded != $line ) {
my $FileContent = "";
my $ErrorMessage;
while (($line, $ErrorMessage) = each(%Errors)){
$FileContent .= $line+1 . ";" . $ErrorMessage . "\n";
}
$Self->{LayoutObject}->Attachment(
Type => 'attachment',
Filename => 'ErrorList.csv',
ContentType => 'text/csv',
Content => $FileContent,
Charset => 'utf-8',
)
}
# start output
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
This downloads the attachment, but does not show the result page:
Code: Select all
my $Output = $Self->{LayoutObject}->Header();
$Output .= $Self->{LayoutObject}->NavigationBar();
# output import results
$Output .= $Self->{LayoutObject}->Block(
Name => 'ImportResult',
Data => {
FileName => $SourceFile{Filename} ||= '',
LinesProcessed => $line,
LinesSuccseeded => $linesSucceeded,
},
);
$Output .= $Self->{LayoutObject}->Output( TemplateFile => 'AgentITSMConfigItemGroupImport', Data => \%Param );
$Output .= $Self->{LayoutObject}->Footer();
# If errors occured export them
if ($linesSucceeded != $line ) {
my $FileContent = "";
my $ErrorMessage;
while (($line, $ErrorMessage) = each(%Errors)){
$FileContent .= $line+1 . ";" . $ErrorMessage . "\n";
}
return $Self->{LayoutObject}->Attachment(
Type => 'attachment',
Filename => 'ErrorList.csv',
ContentType => 'text/csv',
Content => $FileContent,
Charset => 'utf-8',
)
}
return $Output;
S