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, ...
Suggested Answer

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;
        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)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    305,536 Super User 2026 Season 1 on at
    Hi,
     
    I wonder about the contents and purpose of these lines. In case it is only about some text, you can also consider using notes. 
     
    To answer your question, yes it is possible to insert records to the temporary buffer. These records are only used to send to the invoice document and are forgotten at the end of the process. 
     
    You can also insert the lines at another moment in time. When posting the pro-forma invoice, CustInvoiceJour and CustInvoiceTrans records are created. These are converted to the temporary table. After the print job is completed, the records in the CustInvoiceJour and CustInvoiceTrans records are deleted in case of a pro-forma invoice. Instead of adding your additional lines to the temporary buffer, you can also insert them in the CustInvoiceTrans table.

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
Abhilash Warrier Profile Picture

Abhilash Warrier 635 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

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

#3
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 557

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans