web
You’re offline. This is a read only version of the page.
close
Skip to main content
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;;
        }
        
   }
}   
 

I have the same question (0)
  • Anton Venter Profile Picture
    20,303 Super User 2025 Season 2 on at
    RE: To Get Non Posted free text invoices tax rate and tax.

    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
    RE: To Get Non Posted free text invoices tax rate and tax.

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

  • Anton Venter Profile Picture
    20,303 Super User 2025 Season 2 on at
    RE: Class not getting next line when trieng to insert in my table

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

  • Mohit Rampal Profile Picture
    12,563 Moderator on at
    RE: Class not getting next line when trieng to insert in my table

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

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

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 636

#3
Martin Dráb Profile Picture

Martin Dráb 553 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans