Question
“How can I select a default report explorer folder for my end-users to save their reports?”
Solution
The following example uses the Report.Template.OnNew and OnLoadEnd events to set the default folder for the user to save reports.
Download: ReportExplorerSelectDefaultFolder.zip
Sample Delphi code:
procedure TmyEndUserSolution.ehReport_New(Sender: TObject);
begin
ppReportExplorer1.CurrentFolderId := GetFolderId('Customers');
end;
procedure TmyEndUserSolution.ehReport_LoadEnd(Sender: TObject);
begin
ppReportExplorer1.CurrentFolderId := GetFolderId('Customers');
end;
function TmyEndUserSolution.GetFolderId(aFolderName: String): Integer;
var
lsFieldNames: String;
lbFolderExists: Boolean;
begin
// key is folder name, parent id
lsFieldNames := ppReportExplorer1.FolderFieldNames.Name + ';' +
ppReportExplorer1.FolderFieldNames.ParentId;
// locate the folder record
lbFolderExists := ppReportExplorer1.FolderPipeline.Locate(lsFieldNames, VarArrayOf([aFolderName, 0]), [pploCaseInsensitive]);
// return the folder id
if lbFolderExists then
Result := ppReportExplorer1.FolderPipeline[ppReportExplorer1.FolderFieldNames.FolderId]
else
Result := 0;
end;