Dynamics AX Blog - Page 15

These posts are machine-translated.

Post sales packing slip through code

With the help of the following lines, I want to show how you can post a sales packing slip by code.

Those, who want to have more control over the data to be posted, should take a look at the parameters of salesFormLetter.update().

static void postSalesPackingslip(Args _args)
{
    SalesTable salesTable = SalesTable::find("000747");
    SalesFormLetter salesFormLetter;

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::PackingSlip);
    salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All);
}

 
 

Post sales invoice through code

With the help of the following lines, I want to show how you can post a sales invoice by code.

Those, who want to have more control over the data to be posted, should take a look at the parameters of salesFormLetter.update().

static void postSalesInvoice(Args _args)
{
    SalesTable salesTable = SalesTable::find("000747");
    SalesFormLetter salesFormLetter;

    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
    salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All);
}

 
 

Print packing slip through code

The following job demonstrates, how you can print an existing Sales packing slip through code. The example sends the report to screen.

static void printSalesPackingSlipThroughCode(Args _args)
{
    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustPackingSlipJour::findRecId(5637161120));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct();
    salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesPackingSlipJournalPrint.parmUsePrintManagement(false);
    salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesPackingSlipJournalPrint.printJournal(set);
}

Changing the parameter of the instance of SRSPrintDestinationSettings allows you to send the sales packing slip to printer, file or mail. The next example creates a PDF-file.

static void printSalesPackingSlipThroughCode(Args _args)
{
    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustPackingSlipJour::findRecId(5637161120));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
    srsPrintDestinationSettings.fileName(@'c:	emppackingslip.pdf');
    srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
    srsPrintDestinationSettings.numberOfCopies(1);
    srsPrintDestinationSettings.overwriteFile(true);

    // Initalize
    salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct();
    salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesPackingSlipJournalPrint.parmUsePrintManagement(false);
    salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesPackingSlipJournalPrint.printJournal(set);
}

If you want to print multiple sales confirmations at once, you have to add the corresponding CustPackingSlipJour-records to the set called "set:

    ...    
    // Add record
    set.add(CustPackingSlipJour::findRecId(5637155842));
    set.add(CustPackingSlipJour::findRecId(5637145354));
    ...

To additionally save the sales packing slip to print archive, you can add the following line:

    ...    
    srsPrintDestinationSettings.parmPrintToArchive(true);
    ...

 
 

Create primary address through code

The following lines show an example of how you can create a (primary) address for an existing party in the global address book by x ++ code.

The address will only be marked as primary, if no other primary address exists for this party!

static void createPartyAddress(Args _args)
{
    DirPartyTable dirPartyTable = DirPartyTable::findByNum("???100000");
    DirParty dirParty;
    DirPartyPostalAddressView dirPartyPostalAddressView;

    // Create instance of dirParty
    dirParty = DirParty::constructFromCommon(dirPartyTable, DirUtility::getCurrentDateTime(), dirPartyTable.partyType());

    // Create primary address
    dirPartyPostalAddressView.LocationName      = "Office";
    dirPartyPostalAddressView.City              = "Vienna";
    dirPartyPostalAddressView.Street            = "Kärtnerring";
    dirPartyPostalAddressView.StreetNumber      = "18";
    dirPartyPostalAddressView.CountryRegionId   = "AUT";
    dirPartyPostalAddressView.IsPrimary         = NoYes::Yes;

    dirParty.createOrUpdatePostalAddress(dirPartyPostalAddressView);
}

 
 

Print sales confirmation through code

The following job demonstrates, how you can print an existing Sales confirmation through code. The example sends the report to screen.

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustConfirmJour::findRecId(5637155842));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesConfirmJournalPrint = SalesConfirmJournalPrint::construct();
    salesConfirmJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesConfirmJournalPrint.parmUsePrintManagement(false);
    salesConfirmJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesConfirmJournalPrint.printJournal(set);
}

 
 

Print purchase order through code

The following job demonstrates, how you can print an existing Purchase order through code. The example sends the report to screen.

static void printPurchaseOrderThroughCode(Args _args)
{
    PurchPurchOrderJournalPrint purchPurchOrderJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(VendPurchOrderJour::findRecId(5637179849));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    purchPurchOrderJournalPrint = PurchPurchOrderJournalPrint::construct();
    purchPurchOrderJournalPrint.parmPrintFormletter(NoYes::Yes);
    purchPurchOrderJournalPrint.parmUsePrintManagement(false);
    purchPurchOrderJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    purchPurchOrderJournalPrint.printJournal(set);
}

 
 

Print sales invoice through code

The following job demonstrates, how you can print an existing Sales invoice through code. The example sends the report to screen.

static void printSalesInvoiceThroughCode(Args _args)
{
    SalesInvoiceJournalPrint salesInvoiceJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustInvoiceJour::findRecId(5637188088));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesInvoiceJournalPrint = SalesInvoiceJournalPrint::construct();
    salesInvoiceJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesInvoiceJournalPrint.parmUsePrintManagement(false);
    salesInvoiceJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesInvoiceJournalPrint.printJournal(set);
}

 
 
Pages « 1 ... 12 13 14 15 16 17 18 ... 24 » 

 

 
 
 
Posts of the actual month
Mai 2024
MoTuWeThFrSaSu
 12345
6789101112
13141516171819
20212223242526
2728293031 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.