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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Error: The state of the source document or source document line could not be updated. D365FO

(1) ShareShare
ReportReport
Posted on by 406
Hi,
Im doing customization to get data of the selected credit invoicing to the new created free text invoice. but im facing issues with getting lines data.
 
i am receiving the following error: The state of the source document or source document line could not be updated.
basically my issue is in this part because when i commented it, the error is gone:
 
select _custInvoiceLine where _custInvoiceLine.ParentRecId == _custInvoiceTable.RecId;
        _custLineNew.Description =_custInvoiceLine.Description;
        _custLineNew.insert();
        ttscommit;
 
anyone can help me resolve this issue?
I have the same question (0)
  • Raj Borad Profile Picture
    1,428 on at
    Hello User,
     
    You should add after the selection of custInvoiceLine:
    custLineNew.clear();
    custLineNew.initValue();
     
    And also use another ttsbegin & ttscommit for new line entry.
     
    Thank you,
    Raj Borad.
  • D365FO DEV Profile Picture
    406 on at
    Hi @Raj
     
    Thanks for your reply. i applied the changes but error still showing. i debugged the code and the error is showing on the insert method.
     
     
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at
    Hi D365 FO Developer,
     
    In the part where you create the new lines, you aren't providing a value for the ParentRecId to link the line with the new invoice header. You would also need to set a line number field. 
     
    try the next part: 
     
    select _custInvoiceLine where _custInvoiceLine.ParentRecId == _custInvoiceTable.RecId;
            
    __CustLineNew.initValue();
    _custLineNew.ParentRecId = custInvoiceNew.RecId;
    _CustLineNew.LineNum = CustInvoiceLine::lastLineNum_W(_custLineNew.ParentRecId) + 1;
    _custLineNew.Description =_custInvoiceLine.Description;
    _custLineNew.insert();
    
     
    In addition, you would need to provide values for a main account and an amount for the invoice line.
  • D365FO DEV Profile Picture
    406 on at
    Hi Andre,
     
    i have tried your updated code, one issue is the lines are being duplicated. for example, one invoice has 1 line only and im adding this invoice to the credit invoicing. once i selected it, the record is coming on two lines for both new and old invoice. also the data are not showing immediatly unless i refresh the page,

    old invoice:


    New Invoice:


    as you can see its showing two lines instead of 1. also it should show the one with negative qty

    can you help?
  • André Arnaud de Calavon Profile Picture
    301,020 Super User 2025 Season 2 on at
    Hi D365FO ERP Developer,

    Can you share the code you have currently? There was no code shared where you might change the sign of the quantity.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 646 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans