web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX 2012 - AX 2012 - X++ : from code, generating Pro-forma from packing slip & printing with specific design

(0) ShareShare
ReportReport
Posted on by

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);
    }
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    use following code in SalesInvoiceController method outputreport before super()

    formLetterReport.getCurrentPrintSetting().parmReportFormatName(ssrsReportStr(SalesInvoice, SI_Report));

  • AXELOW Profile Picture
    on at

    Hi and thank you for your quick reply.

    Though I didn't try yet to understand why this modification works, it works indeed !

    I now have to see how to add this modification in the main parts which selects PackSlips, post them and print them with my specififc design.

  • Raúl Llorente Peña Profile Picture
    685 on at

    Thanks Peter Niessen-Kruse!!

    I had a similar issue and your answer pointed me to the right direction!!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans