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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Cannot edit a record in Customer invoice lines (CustInvoiceTrans). The operation cannot be completed, since the record was not selected for update. Remember TTSBEGIN/TTSCOMMIT as well as the FORUPDATE clause.

(0) ShareShare
ReportReport
Posted on by

Hi

 When i update  

field on table, is calling this error on line code custInvoiceTrans.update(); Its problem with property update, but whe i need check and resolve this? Please, help.  

public void initQuery()
{
........................
........................
while(queryRun.next())
    {
        queryRun.userUpdate(true);
        custInvoiceTrans = queryRun.get(tableNum(CustInvoiceTrans));
        
            try
            {
                salesLine = SalesLine::find(custInvoiceTrans.SalesId);

                dboSalesAcrossOpsAndRes.InventSiteId = inventSiteId;
                dboSalesAcrossOpsAndRes.CustAccount = custAccount;
                //dboSalesAcrossOpsAndRes.JmgJobId = jobIdProcess;
                //dboSalesAcrossOpsAndRes.RouteOprId = oprId;
                dboSalesAcrossOpsAndRes.SalesId = custInvoiceTrans.SalesId;
                dboSalesAcrossOpsAndRes.InvoiceId = custInvoiceTrans.InvoiceId;
                dboSalesAcrossOpsAndRes.InvoiceDate = custInvoiceTrans.InvoiceDate;
                dboSalesAcrossOpsAndRes.ItemId = custInvoiceTrans.ItemId;
                dboSalesAcrossOpsAndRes.SalesOrderedQty = custInvoiceTrans.Qty;
                dboSalesAcrossOpsAndRes.Weight = custInvoiceTrans.Weight; //salesLine.getGrossWeightPerItem();
                dboSalesAcrossOpsAndRes.SalesLineAmount = salesLine.LineAmount;
                dboSalesAcrossOpsAndRes.ValueByLine = salesLine.LineAmount *
                                                            custInvoiceTrans.Qty;

                dboSalesAcrossOpsAndRes.ValueByWeight = dboSalesAcrossOpsAndRes.Weight *
                                                            dboSalesAcrossOpsAndRes.SalesOrderedQty;

                dboSalesAcrossOpsAndRes.insert();
            ttsBegin;
                custInvoiceTrans.modifiedField(fieldNum(CustInvoiceTrans, DBOProcessed));
                custInvoiceTrans.DBOProcessed = true;
                custInvoiceTrans.update();
            ttsCommit;
                //open form DBOSalesAcrossOpsAndRes
                args = new Args(formStr(DBO_SalesAcrossOpsAndRes));
                formRun = classFactory.formRunClass(args);
                formRun.init();
                formRun.run();

                formRun.detach();


            }


*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Replace with the following code.

    ttsBegin;

    custInvoiceTrans.selectforUpdate(true); // Introduce the following line

    custInvoiceTrans.modifiedField(fieldNum(CustInvoiceTrans, DBOProcessed));

    custInvoiceTrans.DBOProcessed = true;

    custInvoiceTrans.update();

    ttsCommit;

    Hopes this helps you

  • Verified answer
    Community Member Profile Picture
    on at

    this issue is because custInvoiceTrans instance of record is not specified as it is enabled for update

    so before update you should call following statement

    custInvoiceTrans.selectForUpdate(true);

    Please verify and update us if this helps you

  • Verified answer
    Community Member Profile Picture
    on at

    this issue you are getting as you are getting instance of custInvoiceTrans using and query run in a while loop

    it is good way to set the select for update with ttsbegin/ ttcommit be fore update statement

  • maxhammer Profile Picture
    on at

    thank  you, guys

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans