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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Class not getting next line when trieng to insert in my table

(1) ShareShare
ReportReport
Posted on by 1,836

I was trying to insert data using while loop in my new table but it is not getting next line , when i use debugger i shows previous line in line number but i am inserting new line it should show line no 2 but it shoes line 1 in debugger. here is my code below.

 

internal final class DTCustomerNonPostedInV
{
  
	void NonPostedInv()
    {
        CustInvoiceTable                                 custInvoiceTable;
        DTInvoicesLineTmp                                dtInvoicesLineTmp;
        TaxRuntimeDocComponent                           taxRuntimeDocComponent;
        taxDocumentRowTransaction_IN                     taxDocumentRowTransaction_IN;
        taxDocumentRowTransaction                        taxDocumentRowTransaction;
        CustInvoiceLine                                  custInvoiceLine;
        TaxDocumentComponentTransaction                  taxDocumentComponentTransaction;
        TaxRuntimeLookup                                 taxRuntimeLookup;
        CustInvoiceJour                                   custInvoiceJour;
        TaxTrans                                          taxTrans;
        CustInvoiceTrans                                  custInvoiceTrans;
        TaxTable                                          taxTable;
        TaxComponentTable_IN                              taxComponentTable_IN;
        TaxAmountCur                                      sSgst,sIGST,sCGST;
        InvoiceId                                         invoiceId;
        //ParentRecId1                                     parentId;
        LogisticsPostalAddress                           logisticsPostalAddress;
        InventLocationId                                 inventLocationId;
        TransTaxInformation                              transTaxInformation;
        CustTable                                        custTable;
        LogisticsAddressStateId                          companyLocation,customerlocation;
        real                                             GSTRate = 0;
        HSNCodeTable_IN                                  hsntable_IN;
      
        ttsbegin;

        delete_from dtInvoicesLineTmp ;

        ttscommit;
      
        while select * from custInvoiceTable
            where 
                 custInvoiceTable.Posted == NOYES::No
                //&&  custInvoiceTable.InvoiceId == invoiceId
            join  custInvoiceLine
            where custInvoiceLine.ParentRecId == custinvoicetable.RecId
   
        {
            ttsbegin;
            dtInvoicesLineTmp.CustomerAccount = custInvoiceTable.OrderAccount;
            dtInvoicesLineTmp.Name            = custInvoiceTable.Name;
            dtInvoicesLineTmp.InvoiceId       = custInvoiceTable.InvoiceId;
            dtInvoicesLineTmp.LineNum         = custInvoiceline.LineNum;
            dtInvoicesLineTmp.MainAccount     = custInvoiceline.LedgerDimension;
            dtInvoicesLineTmp.Quantity        = custInvoiceline.Quantity;
            dtInvoicesLineTmp.AmountCur       = custInvoiceline.AmountCur;
            dtInvoicesLineTmp.DTChargeCode    = custInvoiceline.DTChargeCode;
            dtInvoicesLineTmp.DTInvoiceId     = custInvoiceline.DTInvoiceId;
            dtInvoicesLineTmp.DTItemId        = custInvoiceline.DTItemId;
            dtInvoicesLineTmp.DTInvoicedate   = custInvoiceline.DTInvoicedate;
            dtInvoicesLineTmp.DTSchemeCharge  = custInvoiceline.DTSchemeCharge;
            dtInvoicesLineTmp.DTInventLocationId  = custInvoiceline.DTInventLocationId;
            dtInvoicesLineTmp.DTInventSiteId  = custInvoiceline.DTInventSiteId;
            dtInvoicesLineTmp.insert();
            ttscommit;;
        }
        
   }
}   
 

  • Anton Venter Profile Picture
    21,242 Super User 2026 Season 2 on at

    How did you approach this? Have you looked at how the standard application calculates the tax when clicking the Sales tax button on the free text invoice?

  • Dineshkarlekar Profile Picture
    1,836 on at

     I am still not getting how to do it because next is not allowed here in code it gives error.

  • Anton Venter Profile Picture
    21,242 Super User 2026 Season 2 on at

    You changed the question instead of creating a new one? Now the reply doesn't match your question.

  • Mohit Rampal Profile Picture
    12,573 Moderator on at

    Hi, Instead of CustInvoiceTable, use CustInvoiceLine in while select and join it with custInvoiceTable so the while loop will iterate for all lines correctly.

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 Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 528 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 424 Super User 2026 Season 2

#3
CU10121822-0 Profile Picture

CU10121822-0 374

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans