Writing a report to file, through code
Below is code that will call the SalesInvoice and generate it as a PDF file:
RecordSortedList List = new RecordSortedList(62);
Id = "SO-0000123";
Select InvJTbl Where InvJTbl.SalesId == Id;
report = new ReportRun(new Args(ReportStr(SalesInvoice)));
This code can be expanded on from here. Hopefully someone can get some use out of this, as we did. To give a better idea, we used this to generate EI's or Electronic Invoices. This was done so that One invoice would exists, instead of having to maintain an Axapta Invoice, and then a Sepearate one for the HTML emailed version that some customers got.
All in all it worked out pretty good, there are some differences though that you have to deal with. The PDF may come out slightly different looking (ie: Company Logo) than what it looks like from within AX.
Find a job at: www.DynamicsAXJobs.com