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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Cannot edit a record in The record shown has been updated by another user

(0) ShareShare
ReportReport
Posted on by 2,050

Greeting everyone 

I've created extension on from table PriceDiscAdmTrans

and add tow 3 fields also 2 method 

1-SnapshotPrice

2-SnapshotCost

3-SnapshotNewCost

and i want to update some fields (SnapshotPrice,SnapshotCost) because value come from extension method but i still getting error message

and here my extension code 

[ExtensionOf(tableStr(PriceDiscAdmTrans))]
final class PriceDiscAdmTrans_Extension
{


    public display real PreviousPrice()

    {
        PriceDiscAdmTrans   priceDiscAdmTrans;
        PriceDiscAdmTable   priceDiscAdmTable;

        select firstfast priceDiscAdmTrans order by RecId desc
            where priceDiscAdmTrans.ItemRelation==this.ItemRelation && priceDiscAdmTrans.relation==PriceType::PriceSales
            && priceDiscAdmTrans.AccountCode==this.AccountCode && priceDiscAdmTrans.AccountRelation==this.AccountRelation
            && priceDiscAdmTrans.ItemCode==this.ItemCode && priceDiscAdmTrans.InventDimId==this.InventDimId
            && priceDiscAdmTrans.FromDate==this.FromDate && priceDiscAdmTrans.ToDate==this.ToDate
        join priceDiscAdmTable where priceDiscAdmTable.JournalNum == priceDiscAdmTrans.JournalNum && priceDiscAdmTable.Posted==true;
        if(!this.SnapshotPrice || this.SnapshotPrice==0)
        {
            this.SnapshotPrice=priceDiscAdmTrans.Amount;
            this.doUpdate();
        }

        return priceDiscAdmTrans.Amount;

    }

    public display real PreviousCost()

    {
        InventTableModule   inventTableModule;
        select * from inventTableModule where inventTableModule.ItemId==this.ItemRelation && inventTableModule.ModuleType==ModuleInventPurchSales::Invent;
        if(!this.SnapshotCost || this.SnapshotCost==0)
        {
            this.SnapshotCost=inventTableModule.Price;
            this.doUpdate();
        }

        return inventTableModule.Price;

    }


}

and i getting on of those error sometimes when i open form

1-Cannot edit a record in Trade agreement journal lines (PriceDiscAdmTrans). The record shown has been updated by another user

2-Cannot edit a record in Trade agreement journal lines (PriceDiscAdmTrans). The record has never been selected.

I have the same question (0)
  • Martin Dráb Profile Picture
    239,580 Most Valuable Professional on at

    Your code looks very wrong indeed.

    You're using display methods to update data, which is a very bad idea. And when you try to save in the form any record that you've modified in your display method, you'll get an update conflict ("The record shown has been updated by another user").

    You'll need to change your approach.

  • mohammed.mqi Profile Picture
    2,050 on at

    thanks for replay

    in which method i should update my data which in current table and row of display method?!

  • Martin Dráb Profile Picture
    239,580 Most Valuable Professional on at

    It depends on what are you trying to implement. Can you explain the business requirements to us, please?

    My guess is that you should maintain this field when saving PriceDiscAdmTrans records.

  • mohammed.mqi Profile Picture
    2,050 on at

    thanks for replay

    i have 2 display method on that table

    PreviousPrice()

    PreviousCost()

    so i need to save them as snapshot on same table

  • ergun sahin Profile Picture
    8,826 Moderator on at

    As far as I can tell from the code you don't expect the values to change. Also, I think that the records you find on the display were created before this record.

    In this case, you can fill these fields by using display methods while trans records are being created.

    If the records are created on the form, you can write the code in trans.init, and if you want to be guaranteed, you can write them in the trans.insert.

    If it is created with code, you need to fill it before insert.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 677 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 620

#3
Subra Profile Picture

Subra 483

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans