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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to print the Customer Statements External(CustAccountStatementExt) Report to pdf through X++ code?

(0) ShareShare
ReportReport
Posted on by 125

Hi,

I am trying to print the 'CustAccountStatementExt' Report to a pdf file through X++ code.

Here is the code I am using. I am trying to create 1 pdf file per customer at a UNC path.

PrintJobSettings                 patPrintJobSettings;
Args                                    args = new Args();

CustTable                           CustTable;

ReportRun                          ReportRun;

SysReportRun                    sysReportRun;
;

patPrintJobSettings = new PrintJobSettings();

CustTable = CustTable::find('00001');

patPrintJobSettings.setTarget(PrintMedium::File);
patPrintJobSettings.preferredTarget(PrintMedium::File);
patPrintJobSettings.format(PrintFormat::PDF);
patPrintJobSettings.preferredFileFormat(PrintFormat::PDF);
patPrintJobSettings.fileName("\\\\VENSANDBOX\\test\\test\\test.pdf");

args.name(reportstr(CustAccountStatementExt));
args.record(CustTable);
args.object(patPrintJobSettings);

new MenuFunction(menuitemoutputstr(CustAccountStatementExt), MenuItemType::Output).run(args);

The problem I am facing with this, is that it is opening a request form, the form that opens when we run the 'CustAccountStatementExt' MenuItem. But, I dont want any user interface. I want to be able to provide the parameters for the report through x++ code through this class I am writing and get the parameters through the dialog for this class as this class extends runbase batch.

Any help is appreciated!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Brandon Wiese Profile Picture
    17,788 on at

    Take a look at Classes\EPSendDocument\makeDocument.  This gives an excellent generalized example of how to generate any report as a PDF with no user input at all.  Note that the EPSendDocument class runs on the server, even though it saves the file on the client (and the specified file path should be appropriate for the client).  I have tried to make the same code run on the client, but there are certain limitations that in the end make no sense (for example, documents with 2 or more pages will often fail on the client).

  • Suggested answer
    uday gujjar Profile Picture
    50 on at

    Email Axapta report as attachment with a modified name Hi All, I am in urgent need of sending Ax report as an attachments with the name of attachment as Clientname_dateofposting pdf. I tried to use element.printjobsettings().filename() for setting the name of attachment but in the Thanks in advance. Deepak, if you want to send a report to a target, you can use this: element.printJobSettings().setTarget(PrintMedium::Mail); You can change the Mail - -> file to a good article http: / / daynamicsaxaptatutorials.blogspot.com / 2010 / 07 / sending-report-through-email-in-axapta.html . I hope it will help  or For any Issues : ON

    Microsoft Dynamics NAV

    Microsoft Dynamics AX

    Microsoft Dynamics CRM

    Microsoft Dynamics  GP

    http://msdynamicsworld.com/

    www.axaptatraining.com/contact.aspx

  • Suggested answer
    uday gujjar Profile Picture
    50 on at

    On Linkedin you will ans on  Groups:

    Dynamics AX Performance Group

    Dynamics NAV - Technical (1450+)

    MICROSOFT DYNAMICS

  • uday gujjar Profile Picture
    50 on at

    Microsoft  Dynamics Drive Application  By Microsoft : Get Register

     

     

    https://vts.inxpo.com/Launch/QReg.htm?ShowKey=7970&LangLocaleID=1033

  • Suggested answer
    uday gujjar Profile Picture
    50 on at

    Microsoft  Dynamics Drive Application  By Microsoft : Get Register

    vts.inxpo.com/.../QReg.htm

  • uday gujjar Profile Picture
    50 on at

    Microsoft  Dynamics Drive Application  By Microsoft : Get Register

    vts.inxpo.com/.../QReg.htm

  • Deepak Agarwal Profile Picture
    8,598 on at

    Hi Try this...

    axtutorials.blogspot.in/.../try-this-code-for-your-report-to-make.html

  • Suggested answer
    Deepak Agarwal Profile Picture
    8,598 on at

    Try THis code

    axtutorials.blogspot.in/.../try-this-code-for-your-report-to-make.html

  • venkatesh vadlamani Profile Picture
    3,180 on at

    Yes there is a way to do this

    1) Go to custAccountStatementExtController class

    2) controllerObj.parmReportContract().parmRDpContract( xobject);

    xobject is the contract objects which has set and get methods for all the DataProvider parameters

    ie CustAccounStatementExtContract class object in this case

    similarly set Rdl contracts also using similar construct.

    how to do it is explained below::

    now in you x++ code create the Xobject before calling the report. Now send it in args .

    Now when you have args.object() pointing to such a class obejcts you use this object to set the report contract as explained in 2) point. in the controller main method itself.

    Now since the report is a document report and has printMgmt completely implemented in ax 2012

    go to the output report method in the above mentioned controller class .Now set  using this kind of construct to set the print destinations over here controllerObj.parmReportContract().PrintContracts(yObject)

    this yObject is printDestinationsettings object.

    you can have for same customer multiple copies and one orginal. For each node runPrintMgmt iterates once. which call ouputreport once in every iteration. If you override in outputReports() method it will be applicable for all the nodes in copy,orginal for this document.

    Hope this helps.

    Now once this is done you can use the mailer code to send as attachment.

    For any thing else you can also reach me at

    venkatesh_vadlamani@hotmail.com

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans