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 :
Supply chain | Supply Chain Management, Commerce
Answered

"Cannot edit a record in Quotation lines" Error When Updating Custom Fields in Sales Quotation Form

(0) ShareShare
ReportReport
Posted on by 109
HI
 
In X++ - Dynamics 365 for Finance and Operations  💚
 
**Updated Problem Description with Item Number:**
I'm working on Dynamics 365 for Finance and Operations. I added two custom fields (NetWeight and GrossWeight) to the SalesQuotationLine table and corresponding columns in the All quotations form. When selecting an ItemId (e.g., item number 1000) in a quotation line, I need to read weight values from the product card (InventTable) and display them in the new columns.
**The Issue:**
When I select item number 1000 in a quotation line using a FormDataFieldEventHandler, the weight values (NetWeight = 235.00) are saved to the database and appear in the columns, but I get an error: "Cannot edit a record in Quotation lines (SalesQuotationLine). The record has never been selected."
**What I've Tried:**
1. Display methods (not being called when selecting item 1000)
2. ModifiedField in table extension (doesn't trigger for item 1000 selection)
3. EventHandler with ds.reread() and ds.refresh() (works for item 1000 but shows error)
4. Used ttsbegin/ttscommit with selectForUpdate(true) and doUpdate() for item 1000
5. Tried update() instead of doUpdate() for item 1000
**Current code works for item 1000 and shows the correct weight values (235.00) but with the "record has never been selected" error. Need solution to remove this error when selecting item 1000.**
 
 
 
 
 
The values ​​are completely correct.
 
 
Please help me resolve this error.
===========================================================================================
X++ Code :
 
class SalesQuotationLine_Written
{
    [FormDataFieldEventHandler(
        formDataFieldStr(SalesQuotationTable, SalesQuotationLine, ItemId),
        FormDataFieldEventType::Modified)]
    public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
    {
        FormDataSource ds = sender.datasource();
        SalesQuotationLine line = ds.cursor();
        if (!line.ItemId)
            return;
        InventTable inventTable = InventTable::find(line.ItemId);
        ttsbegin;
        line.selectForUpdate(true);
        line.NetWeight = inventTable.NetWeight;
        line.GrossWeight = inventTable.GrossWeight();
        line.doUpdate();
        ttscommit;
        ds.reread();
        ds.refresh();
    }
}
===========================================================================================
I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    301,009 Super User 2025 Season 2 on at
    Hi,
     
    In this case, you should not use the update statement as the form is also trying to save details. This is causing the update conflict.
     
    What you can do is extend the mehtod SalesQuotationLine::initFromInventTable via Chain of Commands. Then you only have to fill the values in the record buffer without using a doUpdate command or rereading/refreshing.
     
  • André Arnaud de Calavon Profile Picture
    301,009 Super User 2025 Season 2 on at
    PS. Moved the question from the Dynamics 365 General to the Dynamics 365 SCM forum.
  • Verified answer
    Martin Dráb Profile Picture
    237,866 Most Valuable Professional on at
    André is right. And there are more bugs in your current code. You save the record already when changing item ID, which ignores the fact that the user haven't decided yet to save the record. Also, the record may be invalid (e.g. not all mandatory fields have been populated), so saving doesn't have to be allowed. But you ignore all the validations (validateWrite()) and you save the record anywhere, which might ruin consistency of the database.

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 > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 256 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 205 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

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

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans