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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Automatic Proforma Invoice

(0) ShareShare
ReportReport
Posted on by 5

Hello all,

I have an issue which I was trying to solve on saveral ways but unfortunetly nothing works.

Objective here is to export pro forma invoice to pdf file from code (not to use a standard printing process).  Let's say that I want to create a button to make such export.

I tried to use is code which seems to work but nothing happen:

    SalesTable salesTable;
    PrintJobSettings printJobSettings;
    SalesFormLetter formLetter;

    select firstOnly salesTable
        where salesTable.SalesId == 'YOUR_SALES_ID';

    formLetter = SalesFormLetter::construct(DocumentStatus::Invoice);

    printJobSettings = new PrintJobSettings(formLetter.printerSettingsFormletter());
    printJobSettings.setTarget(PrintMedium::File);
    printJobSettings.format(PrintFormat::PDF);
    printJobSettings.fileName(@'C:\Temp\proforma_invoice.pdf');

    formLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
    formLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

    formLetter.update(salesTable,
                        systemDateGet(),
                        SalesUpdate::All,
                        AccountOrder::None,
                        NoYes::Yes,
                        NoYes::Yes);

Version: AX 2012 R3

Please help!

I have the same question (0)
  • dklimke Profile Picture
    20 on at

    Hi,

    i store the pdf to the print archive and then get the pdf as binary buffer or bin container from the docuref.

        public FormLetterToPrintArchiveResponse saveInvoiceFormLetterToPrintArchive(SalesId _salesId, SalesUpdate _specQty, boolean _proforma)
        {
            FormLetterToPrintArchiveResponse   		ret             = new FormLetterToPrintArchiveResponse();
            SalesFormLetter                         salesFormLetter =  SalesFormLetter::construct(DocumentStatus::Invoice);
            SalesParmLine                           parmLine;
            SalesLine                               salesline;
            SalesTable                              localSalesTable;
            SRSPrintDestinationSettings             printerSettings = new SRSPrintDestinationSettings();
    
            guid uid = newGuid();
            str fn_noext = guid2Str(uid);
            Filename fn = strFmt("%1.pdf", fn_noext);
    
            localSalesTable = SalesTable::find(_salesId);
    
            SRSPrintArchiveContract ac = new SRSPrintArchiveContract(SRSReportFileFormat::PDF);
            printerSettings.parmSRSPrintArchiveContract(ac);
            printerSettings.printMediumType(SRSPrintMediumType::Archive);
            printerSettings.fileFormat(SRSReportFileFormat::PDF);
            printerSettings.overwriteFile(true);
            printerSettings.fileName(fn);
            salesFormLetter.updatePrinterSettingsFormLetter(printerSettings.pack());
            
            salesFormLetter.update(localSalesTable, systemDateGet(), _specQty, AccountOrder::None, _proforma, true, false); 
    
            DocuRef docuRef;
    
            select firstonly docuRef
                where   docuRef.RefTableId == tableNum(PrintJobHeader)
                &&      docuRef.Name == fn_noext
                &&      docuRef.ActualCompanyId == curExt();
    
            ret.parmDocuRef(docuRef);
            ret.parmFileName(fn);
            ret.parmFileNameWithoutExtension(fn_noext);
            ret.parmPrinJobHeaderRecId(docuRef.RefRecId);
    
            return ret;
        }

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 679 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 421 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 282 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans