Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to Invoice multiple sales order with single InvoiceId using SalesFormLetter?

(0) ShareShare
ReportReport
Posted on by 926

Hello everyone,

I have tried multiple ways to invoice multiple sales orders combined. How to achieve this through code. 

Here is my final approach. It is Invoicing separately, not a single invoice.

public static void main(Args _args)
    {
        SalesFormLetter salesFormLetter;
        SRSPrintDestinationSettings printSettings;
        SysQueryRun queryRun;
        QueryBuildRange queryRange;
        Query query;
        str strSalesTable = "SO-D00000222, SO-D00000223";
        ;

        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
		
        query = new Query(QueryStr(SalesUpdate));
        queryRange = query.dataSourceTable(tablenum(SalesTable)).addRange(fieldnum(SalesTable, SalesId));
        queryRange.value(strSalesTable);

        queryRun = new SysQueryRun(query);

        salesFormLetter.chooseLinesQuery(queryRun);
        salesFormLetter.transDate(systemdateget());
        salesFormLetter.specQty(SalesUpdate::All);
        salesFormLetter.sumBy(AccountOrder::Account);
        salesFormLetter.showQueryForm(false);
        salesFormLetter.printFormLetter(true);
        
        
        //salesFormLetter.reArrange();
        
        salesFormLetter.chooseLines();

        salesFormLetter.run();
    }

What am I doing wrong? Please help me!

Regards,

Khurshid Wali

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,160 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans