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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Inserting supplementary rows into SalesInvoiceTmp

(0) ShareShare
ReportReport
Posted on by
Hi community,

I have a requirement to insert additional rows into a sales pro forma invoice. These rows are created on the SalesLine table with a 0 quantity thus they have no LotId and standard logic does not insert them into SalesInvoiceTmp.

Below my code to insert said records, I want to confirm that it is safe to call the standard method this.insertIntoSalesInvoiceTmp() in this way, with a in-memory buffer of CustInvoiceTrans.

Since this only applies to pro forma I expect any possible transaction in scope to be rolled back, and from what I can see there is no logic in the insertIntoSalesInvoiceTmp() call stack that would persist the CustInvoiceTrans buffer.

Or would you advise rather writing bespoke logic to insert the required fields directly into SalesInvoiceTmp from the  DP_Extension class and to not call this standard insertIntoSalesInvoiceTmp() method.
 
[ExtensionOf(classStr(SalesInvoiceDP))]
final class ABCSalesInvoiceDP_Extension
{
    public void generateInvoiceRelatedInformation(CustInvoiceJour _custInvoiceJour)
    {
        next generateInvoiceRelatedInformation(_custInvoiceJour);

        if (_custInvoiceJour.isProforma())
        {
            this.abcPopulateSomeItems(_custInvoiceJour);
        }
    }

    private void abcPopulateSomeItems(CustInvoiceJour _custInvoiceJour)
    {
        SalesTable          salesTable = _custInvoiceJour.salesTable();
        SalesLine           SalesLine;
        InventTable         InventTable;
        CustInvoiceTrans    custInvoiceTransBuffer;

        while select SalesLine
        where SalesLine.Field == SomeValue
        {
            custInvoiceTransBuffer.clear();
            custInvoiceTransBuffer.initValue();
            custInvoiceTransBuffer.initFromCustInvoiceJour(_custInvoiceJour);
            custInvoiceTransBuffer.initFromSalesLine(SalesLine);

            this.insertIntoSalesInvoiceTmp(_custInvoiceJour, custInvoiceTransBuffer, null, null, null, null);
        }
    }
}
 
Categories:
I have the same question (0)

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 676

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 635 Super User 2026 Season 1

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 605 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans