Hi,
I would like to print several packing slip documents to file (pdf) simultaneously.
Either from Accounts receivable - periodic - sales update - packing slip and do a select for a number of orders to print packing slip to file or from the print archieve if this would facilitate in any way.
Example:
1. Do a select which returns for example 30 sales orders
2. Post packing slip/print without posting packing slip for these orders
3. Get all packing slips either in one pdf or in 30 different packing slips.
What I would like to avoid is to post all packing slips, print to screen and then go through each packing slip and save it as pdf to disk.
Thanks in advance!
*This post is locked for comments
Henrik, you can do this with a bit of coding. You need to use CustPackingSlipJour table to select the packing slips you want to print, and then loop through all records and print individual packing slip reports using the SalesFormLetter class (which actually instances SalesFormLetter_PackingSlip class when constructed for packing slips).
Here's the sample code that creates PDF printouts for all packing slips for a selected date (in this exaple I used the latest date from CustPackingSlipJour table), you can adjust it to your requirements (e.g. change select criteria, use different folder for PDF files, etc.).
// 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);
}
}
Dear Matt and Steeve,
I appreciate you taking time to help me out with this.
However, it seems that I have somewhat not managed to point to my real problem. I do know how to select the sales orders I want, and how to post and print without posting and choosing PDF file as print option.
The problem is that you will only get one pdf, which just contains just one of the packing slips.
I am not a developer myself, and I won't be changing any code to solve this problem. But from what I gather from you there is no way to make this work with standard functionality?
Thanks again!
//Henrik
(1) How to select orders and display the packing slip posting form. It's easier when you do that on a form that have the SalesTable dataSource with a grid. Like SalesTable form, but you can also build a custom one.
SalesTable_ds.query().dataSourceNo(1).addRange(fieldNum(SalesTable, SalesId)).value("SalesId you want to select");
SalesTable_ds.executeQuery();
// Select all wanted lines
salesTabToSelect = SalesTable_ds.getFirst();
while (salesTabToSelect)
{
SalesTable_ds.markRecord(salesTabToSelect, true);
salesTabToSelect = SalesTable_ds.getNext();
}
args.parmEnumType(typeId(DocumentStatus));
args.parmEnum(DocumentStatus::PackingSlip);
args.record(SalesTable);
//Open posting form
SalesFormLetter::main(args);
(2) \Classes\SalesEditLinesForm_PackingSlip. You should be able to control the posting checkbox from here to post or not. And probably control the "Ok" button to post automatically.
(3) \Classes\SalesFormLetter_PackingSlip\initPrinterSettingsFormletter. From there, set the printJobSetting object to default to PDF and specify a filename.
Problem my arise if multiple packing slip are created, i guess the PDF will be overwritten for every packing slip until the last. You will probably have to skip the call to "element.reset()" in the report so that only one report (PDF) is generated.
It's a good challenge you got there. Hope that helps. If you have other question let us know.
In AR->Periodic->Sales update->Packing slip
Unchecking "Posting" will prevent the packing slips from actually being posted in AX. Make sure "Print packing slip" is still checked.
To save to PDF, on the right hand side click on "Printer setup". Choose "File" and in the drop down select "PDF".
That should give you one PDF with all the Packing Slips you selected.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156