Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

Sales invoice report - download multiple sales invoice on a single button click

(0) ShareShare
ReportReport
Posted on by 129

Hi experts

I am working on Sales invoice report and the requirement is that -

We select multiple invoices and add one button. On the button click selected invoices download into archive folder.

I tried all ways but no luck.

I am looking your help. Kindly suggest some solution

many thanks in advance.

Below things I have done:

1. created new controller class and wrote below code but got the currency exchange related error that is the reason wrote exchange rate related ocde but

    still I am getting the same exchange rate related error

public class XXXSalesInvoiceController extends SrsReportRunController

{

public static void main(Args _args)

{
XXXSalesInvoiceController controller = new XXXSalesInvoiceController();
SalesInvoiceContract rdpContract = new SalesInvoiceContract();
ExchangeRateHelper exchangeRateHelper = ExchangeRateHelper::construct();
exchangeRateHelper.parmFromCurrency("USD");

controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(XXX_SalesInvoice, Report));
controller.parmShowDialog(false);
controller.parmReportContract().parmRdpContract(rdpContract);

str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
SRSPrintDestinationSettings printerSettings = controller.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.parmFileName('custInvoiceJour.InvoiceId' + ext);
printerSettings.overwriteFile(true);

controller.startOperation();
}

2. My second attempt is:

ExtensionOf(classStr(PrintMgmtReportRun))]
final class XXX_PrintMgmtReportRun_Class_Extension

{

public void loadSettingDetail(PrintMgmtPrintSettingDetail _settingDetail, str _documentKeyValue)
{
SalesInvoiceController invController;
CustInvoiceJour custInvoiceJour;

if (this.parmDocType() == PrintMgmtDocumentType::SalesOrderInvoice)
{
if (ssrsReportStr(XXX_SalesInvoice, Report) == this.parmReportRunController().parmReportName())
{
invController = this.currentController;
custInvoiceJour = invController.parmArgs().record() as CustInvoiceJour;

_settingDetail.parmReportFormatName(ssrsReportStr(SalesInvoice, Report));


str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
SRSPrintDestinationSettings printerSettings = invController.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.parmFileName(custInvoiceJour.InvoiceId + ext);
printerSettings.overwriteFile(true);

}
}

next loadSettingDetail(_settingDetail, _documentKeyValue);
}

3. Third attempt:

[ExtensionOf(classStr(SalesInvoiceController))]
final public class XXX_SalesInvoiceController_Class_Extension
{

protected void runPrintMgmt()
{

  str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
 SRSPrintDestinationSettings printerSettings;// = formLetterReport.parmReportContract().parmPrintSettings();  // unable to get control instance
 printerSettings.printMediumType(SRSPrintMediumType::File);
 printerSettings.fileFormat(SRSReportFileFormat::PDF);
 printerSettings.parmFileName('custInvoiceJour.InvoiceId' + ext);
 printerSettings.overwriteFile(true);

next runPrintMgmt();
}

protected void prePromptModifyContract()
{
next prePromptModifyContract();

SalesInvoiceContract contract = this.parmReportContract().parmRdpContract() as SalesInvoiceContract;
if(this.parmArgs().dataset() == tableNum(CustInvoiceJour))
{
CustInvoiceJour custInvoiceJour = this.parmArgs().record() as CustInvoiceJour;
contract.parmRecordId(CustInvoiceJour.RecId);

str ext = SRSPrintDestinationSettings::findFileNameType(SRSReportFileFormat::PDF, SRSImageFileFormat::BMP);
SRSPrintDestinationSettings printerSettings = this.parmReportContract().parmPrintSettings();
printerSettings.printMediumType(SRSPrintMediumType::File);
printerSettings.fileFormat(SRSReportFileFormat::PDF);
printerSettings.parmFileName(custInvoiceJour.InvoiceId + ext);
printerSettings.overwriteFile(true);
}
}

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,971 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,846 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans