By now one thing should be clear: Microsoft wants us all to switch to SSRS reporting.
But in my opinion standard Ax reporting is useful and exposing it shouldn't be so hard. Invoices for instance: Customers should really be able to download them from your site, so I have crafted a sample that writes a report to PDF and then offers users to download it through a text and image web link.
I've done this for EP 3.0 as well, and it is actually a lot easier, but the basics remain the same. At the core is the DataSet method X++ code that generates the report.
First, somewhere in your .NET user control*, preferably as the invoice details page loads (The Page_Load method for instance), call your dataset method.
* In a webdefined control in Ax 3.0 Enterprise Portal (override the layout method instead).
private string InvoiceId;
private string pdfUrl = "about:blank";
protected void Page_Load(object sender, EventArgs e)
InvoiceId = Page.Request.QueryString.Get("IID"); // I passed the invoice id from the grid as a GET parameter
pdfUrl = "http://192.168.88.5:8080/Invoice_" + InvoiceId + ".PDF"; //obviously hard coding isn't the way to go
CustInvoiceJour_DS.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("CreatePDF", InvoiceId); //This is the call to our DataSet method that initiates the X++ code
InvoiceLink.NavigateUrl = pdfUrl; //
Here is the X++ DataSet method that generates the PDF invoice.
NOTE: Remember to host the folder as a site in IIS, or use one of Enterprise Portal's public folders. Also, restrict browsing folder contents and remember to delete sensitive customer data after a short while.
NOTE 2: In Ax 3.0 this code must be in the Web Forms run method.
public str CreatePDF(InvoiceId _invoiceId)
//Declare SalesFormLetter and PrintJobSettings objects
SELECT firstonly cij
where cij.invoiceId == _invoiceId;
parameters = new Args(ReportStr(SalesInvoice));
printJobSettings = new PrintJobSettings();
printJobSettings.preferredMailFormat(PrintFormat::PDF); //Not necessary, but residue from the days this method sent an email instead.
printJobSettings.fileName(@"\\THINK\pdfhost\Invoice_" + cij.invoiceId + ".PDF"); //Write to the IIS hosted virtual directory
salesFormLetter = new SalesFormLetter_Invoice(false);
parameters.parmEnum(PrintCopyOriginal::OriginalPrint); //I had to use PrintCopyOriginal::OriginalPrint, instead of ::Original, as other bloggers recommend. Failing to do so meant, in 2009, that the PDF wasn't saved to the file system. In 3.0 ::Original worked just fine.
reportRun = new ReportRun(parameters);
Hope this helps someone out there!
Thanks to Brandon George and other bloggers out there.
Also: Thank you to Justin Biggs