web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Sales invoice report - After export first invoice as pdf it stops and not executing next invoices

(0) ShareShare
ReportReport
Posted on by 737

Hi experts,

I wants to exports more than one sales invoice separately as pdf, Its working fine for first invoice but not executing for next invoice, Here is my code, its working fine for my custom report but not working for standard sales invoice report

//Calling sales invoice controller

args.record(custInvoiceJour);
args.parm(_seconds);
new MenuFunction(menuitemOutputStr(SalesInvoiceOriginal), MenuItemType::Output).run(args);

//Controller class code

public static void main(Args _args)
{

custinvoicejour custinvoicejour;

SrsReportRunImpl srsReportRun;
Filename reportName;
SrsPrintMgmtExecutionInfo reportExecutionInfo;//Added by BKS
salesInvoiceContract salesInvoiceContract;

;

custinvoicejour = _args.Record();

salesInvoiceController.parmIsGSTInvoice_IN(true);
formLetterController.parmReportName(ssrsReportStr(SalesInvoice_IN, GSTReport));

reportName = CustInvoiceJour.InvoiceId + strReplace(strFmt(" %1",CustInvoiceJour.InvoiceDate),'/','.');

reportExecutionInfo = salesInvoiceController.parmReportContract().parmReportExecutionInfo() as SrsPrintMgmtExecutionInfo;
if (!reportExecutionInfo)
{
reportExecutionInfo = new SrsPrintMgmtExecutionInfo();
}
reportExecutionInfo.parmOriginalDestinationFileName('c:\\users\\Public\\'+ reportName +'.pdf');
salesInvoiceContract = salesInvoiceController.parmReportContract().parmRdpContract();
salesInvoiceContract.parmRecordId(CustInvoiceJour.RecId);
salesInvoiceContract.parmCountryRegionISOCode(SysCountryRegionCode::countryInfo());
//salesInvoiceContract.parmArgs(_args);
srsReportRun = salesInvoiceController.parmReportRun() as SrsReportRunImpl;
salesInvoiceController.parmReportRun(srsReportRun);

salesInvoiceController.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);

salesInvoiceController.parmReportContract().parmPrintSettings().overwriteFile(true);

salesInvoiceController.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);
salesInvoiceController.parmReportContract().parmPrintSettings().fromPage(1);
salesInvoiceController.parmReportContract().parmPrintSettings().toPage(1);
salesInvoiceController.parmReportContract().parmReportExecutionInfo(reportExecutionInfo);
salesInvoiceController.parmReportContract().parmPrintSettings().fileName('c:\\users\\Public\\'+ reportName +'.pdf');

salesInvoiceController.runReport();

}

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    304,323 Super User 2026 Season 1 on at

    Hi B K Sharma,

    The only data related call, I notice is: "custinvoicejour = _args.Record();". This is a single record only. There is no loop in this method. So, it will indeed run for only one invoice. Is there another method with a loop? If not, you have to change the coding and implement looping records.

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    Are you calling this  code in a loop ? Where did you put this code ?

  • B K Sharma Profile Picture
    737 on at

    Hi Sukrut/André Arnaud de Calavon,

    Yes I am calling this code in a loop, Now Issue has been identified where same file name was passing in both  Controller and SrsPrintMgmtExecutionInfo , So this was copying same file to same file, Now I have changes the executioninfo file name but Now each file saving as pdf two times, one by controller class and another one is execution info class, But I need only a single copy for each invoice, Where I am making mistake in this

    salesInvoiceController.parmReportContract().parmPrintSettings().fileName('c:\\users\\Public\\'+ reportName +'.pdf');

    reportExecutionInfo.parmOriginalDestinationFileName('c:\\users\\Public\\'+ reportName +'.pdf');

    What exactly SrsPrintMgmtExecutionInfo class doing here, If I do not use this class method than I am Getting "Parameter executionInfo cannot be null or empty." error

  • B K Sharma Profile Picture
    737 on at

    Hi Sukrat,

    Can you pls help me, why 2 pdf file generating for each invoice, What exactly SrsPrintMgmtExecutionInfo class doing here, If I do not use this class method than I am Getting "Parameter executionInfo cannot be null or empty." error.

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    Did you try removing below line and see what happens ?

    salesInvoiceController.parmReportContract().parmPrintSettings().fileName('c:\\users\\Public\\'+ reportName +'.pdf');

    SrsPrintMgmtExecutionInfo class contains information about reports executed in print management

  • B K Sharma Profile Picture
    737 on at

    Then system validating file name can not be blank, Need to understand the concept of execution info to implement it in report export as pdf.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 26

#2
imran ul haq Profile Picture

imran ul haq 8

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 4 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans