Skip to main content

Notifications

Announcements

No record found.

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 230,198 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 230,198 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans