Skip to main content

Notifications

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

Error executing code: The field with ID '0' does not exist in table ''.

Posted on by 1,457
I have created the extension of salescopying form , when i click on ok button this error getting triggred , i am not getting how to resolve it 
can anyone plz help , 
error 
Error executing code: The field with ID '0' does not exist in table ''.
[ExtensionOf(formStr(SalesCopying))]final class DTSalesCopying_Extension{    public void closeOk()    {        next closeOk();        CustInvoiceJourcustInvoiceJour = this.dataSource(/CustInvoiceJour/).cursor();        SalesTablesalesTable = this.args().record();        SalesTablesalesTableupdate;        update_recordset salesTableupdate                setting DTOriginalInvoiceId = custInvoiceJour.InvoiceId,                DTOriginalSalesId = custInvoiceJour.SalesId                where salesTableupdate.SalesId == salesTable.SalesId;    }}
i have added 2 fields on salestable extension .
 
  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 229,918 Most Valuable Professional on at
    Error executing code: The field with ID '0' does not exist in table ''.
    You don't need to call initFromCustInvoiceJour() by yourself - it's already done by F&O, as far as I know.
     
    canClose() method of SalesCopying form calls canClosePostProcess(). This calls SalesCopying::copyServer(), which creates an instance of SalesCopying and calls its copy() method. copy() calls copyHeader() (among other things), which calls copyFromSourceTable(). This method instantiate a child of SalesTableCopyFromSource, namely SalesTableCopyFromCustInvoiceJour, which calls SalesCopying.initHeaderFromCustInvoiceJour(). There you can see the call of initFromCustInvoiceJour():
    public void initHeaderFromCustInvoiceJour(CustInvoiceJour _custInvoiceJour)
    {
        salesTable.initFromCustInvoiceJour(_custInvoiceJour);
    }
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    Error executing code: The field with ID '0' does not exist in table ''.
    hi
    martin actually i was trying to update this two field on return sales order form on the when i click on sales copying form ,plz can you guide me on this . 
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    Error executing code: The field with ID '0' does not exist in table ''.
       if i put this on SalesTable.initFromCustInvoiceJour() how can i put this on close of salescopying
     
    thanks ,
    regards ,
    Dinesh
  • Dineshkarlekar Profile Picture
    Dineshkarlekar 1,457 on at
    Error executing code: The field with ID '0' does not exist in table ''.
    I martin is it right to do like this , here is my code 
    [ExtensionOf(formStr(SalesCopying))]
    final class DTSalesCopying_Extension
    {
        public void closeOk()
        {
            next closeOk();
            CustInvoiceJour	custInvoiceJour = this.dataSource("CustInvoiceJour").cursor();
            SalesTable	salesTable = this.args().record();
            SalesTable	salesTableupdate;
         
            if(salesTable.DTOriginalSalesId = "" && salesTable.DTOriginalSalesId = "")
            {
    
                ttsbegin;
                salesTable.initFromCustInvoiceJour(custInvoiceJour);
    
                update_recordset salesTableupdate
                        setting DTOriginalInvoiceId = custInvoiceJour.InvoiceId,
                        DTOriginalSalesId = custInvoiceJour.SalesId
                        where salesTableupdate.SalesId == salesTable.SalesId;
                ttscommit
            }
        }
    
    }
    thanks
    ,regards,
    Dinesh
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 229,918 Most Valuable Professional on at
    Error executing code: The field with ID '0' does not exist in table ''.
    Your design looks very wrong to me. You're assuming that SalesCopying form is never used for anything else than copying from CustInvoiceJour, and you put the logic to a wrong place. The most logical place for it is SalesTable.initFromCustInvoiceJour(). It's not only much better, but it's also less work and there are less chances to write code in a wrong way.
     
    If you don't want to use initFromCustInvoiceJour() for some reason, then use SalesCopying.initHeaderFromCustInvoiceJour().

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,113 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,918 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans