Hello everybody,
I have also checked previous posts and didn't find the right answer, but I may not have searched the right way.
(Best article I found was this one, but applies to AX2009 unfortunatly : https://community.dynamics.com/product/ax/f/33/p/47302/85894.aspx)
Anyway, here is my goal :
1/I want to create a profoma invoice from a packing slip order, or from several
2/I want to use a specific design, let's say SalesInvoice.SI_invoice for printing in file pdf named "packingSlipId.pdf"
3/I want all this to happen when clicking a button located in the PackingSlip Journal Form, which does the 2 previous tasks to all selected PackingSlip Orders. I also don't want any Print Form to prompt on screen when clicking that button, all this should happen automatically.
Here are my problems :
I found many helpful code samples, but all apply to AX2009 only.
(You will find below the best I managed to find)
-I can post my packing slip order using the formLetter.update() method
-I am not able to control any bit of the printing methods.
When I chose my specific design, SalesInvoice.SI_Report in SalesI nvoiceController., it still prints the document using the old design SalesInvoice.Report; even if this design doesn't exist anymore in the AOT ! And when I save my report from screen, it choses the name : SalesInvoice.SI_Report, which drives me crazy...If it prints using SalesInvoice.Report, it should at least save with the name SalesInvoice.Report...
Here is what I do:
In SalesInvoiceController.Main()
formLetterController.parmReportName(PrintMgmtDocType::construct(PrintMgmtDocumentType::SI_SalesOrderInvoice).getDefaultReportFormat());
In PintMngtDocType.getDefaultReportFormat()
case PrintMgmtDocumentType::SI_SalesOrderInvoice:
return ssrsReportStr(SalesInvoice, SI_Report);
Please, any help on printing management would be very sooo welcome :(
Here's a very good code sample, for AX2009 :
// Created on 11 Jan 2011 by Jovan Bulajic
static void PrintPackingSlipsToPDF(Args _args)
{
CustPackingSlipJour custPackingSlipJour;
SalesFormLetter packingSlip;
PrintJobSettings printSet;
TransDate filterDate;
Filename pdfFile;
;
// Configure printer/PDF settings
printSet = new printJobSettings();
printSet.setTarget(PrintMedium::File);
printSet.format(PrintFormat::PDF);
printSet.warnIfFileExists(false);
printSet.suppressScalingMessage(true);
printSet.setTarget(PrintMedium::File);
// Initialize the report
packingSlip = SalesFormletter::construct(DocumentStatus::PackingSlip, false);
// Select date of the latest packing slip (e.g. today - to use this for testing)
select maxOf(DeliveryDate) from custPackingSlipJour;
filterDate = custPackingSlipJour.DeliveryDate;
info(strFmt('Printing Packing Slips for %1', filterDate));
// Process all packing slips for the selected date
while select *
from custPackingSlipJour
where custPackingSlipJour.DeliveryDate == filterDate
{
// Set the PDF file name
pdfFile = strFmt('C:\\Temp\\PackingSlip_%1.pdf', custPackingSlipJour.PackingSlipId);
printSet.fileName(pdfFile);
// Print packing slip to PDF
packingSlip.updatePrinterSettingsFormLetter(printSet.packPrintJobSettings());
custPackingSlipJour.printJournal(packingSlip);
}
}