Thanks a lot.
I found a way to implement a selection dialog (community.dynamics.com/.../turn-report-selections-into-a-selection-dialog).
Now I get the selected report of the selection dialog but since I can't implement the function into the document print code unit I have added the code to the first report that gets called.
This is my selection dialog code, which I put into my OnInitReport function.
ReportSelection.SETFILTER("Report ID", '<>0');
ReportSelection.SETRANGE(Usage, ReportSelection.Usage::"S.Quote");
IF ReportSelection.Count < 2 THEN
EXIT;
OptionStr := '';
IF ReportSelection.FINDSET THEN
REPEAT
ReportSelection.CALCFIELDS("Report Caption");
OptionStr += ReportSelection.Sequence + ' ' + ReportSelection."Report Caption" + ',';
UNTIL ReportSelection.NEXT = 0;
Selection := STRMENU(OptionStr, 1);
If Selection = 0 THEN
ERROR('');
ReportSelection.FINDFIRST;
FOR ReportIndex := 2 TO Selection DO BEGIN
ReportSelection.NEXT;
END;
ReportSelection.SETRANGE(Sequence, ReportSelection.Sequence);
ReportSelection.CALCFIELDS("Report Caption");
CurrentReportID := COPYSTR(CurrReport.OBJECTID(FALSE), 1+STRPOS(CurrReport.OBJECTID(FALSE), ' '));
SelectedReportID := FORMAT(ReportSelection."Report ID");
IF CurrentReportID = SelectedReportID THEN BEGIN
MESSAGE('Equal');
END
ELSE BEGIN
MESSAGE('Not Equal');
END;
When I click on the print button I can select between 3 reports ("quote 1" -> calls the function, "quote 2", "quote 3").
How can I print only the selected report?