If you are developing solutions with some automated procedures on sales orders or purchase orders, you might want to control how documents are being printed from the orders. These examples show you how to control this with X++ code.
The SalesFormLetter and PurchFormLetter classes has methods that gives you an easy interface to change the printer settings for a sales order or a purchase order document.
The following example shows you how to open the printer settings dialog and let the user change these for later use:
static void CallFormLetterPrinterSettings(args a)
{
SalesFormLetter salesFormLetter;
;
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.getLast();
SalesFormLetter::callPrinterSettingsFormletter(salesFormLetter);
salesFormLetter.saveLast();
}
This next example shows you how to change the printer settings without the user dialog:
static void ChangeFormLetterPrinterSettings(args a)
{
SalesFormLetter salesFormLetter;
PrintJobSettings printJobSettings;
;
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.getLast();
// Create new instance of PrintJobSettings, with the settings from the SalesFormLetter printJobSettings = new PrintJobSettings(salesFormLetter.printerSettingsFormletter());
// Change the number of copies to 17
// (Remember to change it back! The world is already loosing rainforest at a much to fast pace)
printJobSettings.copies(17);
// Pack and update the settings on the SalesFormLetter salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings()); salesFormLetter.saveLast();
}
static void ChangeFormLetterPrinterSettings(args a)
{
SalesFormLetter salesFormLetter;
PrintJobSettings printJobSettings;
;
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.getLast();
// Create new instance of PrintJobSettings, with the settings from the SalesFormLetter printJobSettings = new PrintJobSettings(salesFormLetter.printerSettingsFormletter());
// Change the number of copies to 17
// (Remember to change it back! The world is already loosing rainforest at a much to fast pace)
printJobSettings.copies(17);
// Pack and update the settings on the SalesFormLetter salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings()); salesFormLetter.saveLast();
}
No comments:
Post a Comment