Hi everyone,
This is the code of function SendRecords in table 112 Sales Invoice Header.This code is used when we want to print one or many invoices from the posted invoices list:
LOCAL SendRecords(ShowRequestForm : Boolean;SendAsEmail : Boolean)
WITH SalesInvoiceHeader DO BEGIN
COPY(Rec);
ReportSelections.SETRANGE(Usage,ReportSelections.Usage::"S.Invoice");
ReportSelections.SETFILTER("Report ID",'<>0');
ReportSelections.FIND('-');
REPEAT
IF NOT SendAsEmail THEN
REPORT.RUNMODAL(ReportSelections."Report ID",ShowRequestForm,FALSE,SalesInvoiceHeader)
ELSE
SendReport(ReportSelections."Report ID",SalesInvoiceHeader)
UNTIL ReportSelections.NEXT = 0;
END;
Let's say I selected two records, I want the invoices to be printed separately (get the request page displayed twice, and the records printed one by one).
I tried the following:
WITH SalesInvoiceHeader DO BEGIN
COPY(Rec);
IF FINDSET THEN
REPEAT
ReportSelections.SETRANGE(Usage,ReportSelections.Usage::"S.Invoice");
ReportSelections.SETFILTER("Report ID",'<>0');
ReportSelections.FIND('-');
REPEAT
IF NOT SendAsEmail THEN
REPORT.RUNMODAL(ReportSelections."Report ID",ShowRequestForm,FALSE,SalesInvoiceHeader)
ELSE
SendReport(ReportSelections."Report ID",SalesInvoiceHeader)
UNTIL ReportSelections.NEXT = 0;
UNTIL (NEXT =0);
END;
This way, I got the request page displayed twice, but each time I got the two records printed, not just the current one...
How can I achieve what I described, any ideas?
Thanks in advance
Comments
Runmodal doesnt care which Record (invoice) you currently hold, its all about the filter.