Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Strange error message ...
Finance forum
Answered

Strange error message when tried to update a record from a form

Posted on by 30

Hello. This is my first post on this forum, I'm not even sure whether this is the right forum for the question. If it's not, please redirect me to the right forum.

So I have a form which is used for displaying and maintaining data from a Setup table. The table has a field named SetupMainAccount, which is related to the system table MainAccount through its field RecId. The field shows Account Number from the MainAccount table, but the client also wants to see the Account Number value in a separate column. So I've done it by adding MainAccount table to the form's data sources, along with my main Setup table, and specified the relation between the two data sources. The MainAccount data source's properties Allow Create, Delete and Edit are all set to No, because I don't want any data from this table to be updated through this form. I have then added the MainAccount.Name field to the data grid, and everything looks fine initially. The problems begin when I change the Account number value from the dropdown in the grid, and try to save the record, the following message pops up:

6874.pastedimage1663166317554v1.png

Does anybody know what causes this message. I have not called this function, but I have found that this function is called from the MainAccount table class's update method. It probably means that update of MainAccount  table's record is attempted, but how can I prevent it?

  • Ascalab Profile Picture
    Ascalab 30 on at
    RE: Strange error message when tried to update a record from a form

    You're goshoom , I've created the new thread. Please respond there if you can.

  • Martin Dráb Profile Picture
    Martin Dráb 228,135 Most Valuable Professional on at
    RE: Strange error message when tried to update a record from a form

    It would be indeed better in a new thread, because it's not about "Strange error message when tried to update a record from a form".

    The related record indeed isn't loaded from database when you merely change a value of the other field (and you don't save the change to DB). But if you want to show it to users immediately, you can override modified() method of the data source field and implement the logic there.

  • Ascalab Profile Picture
    Ascalab 30 on at
    RE: Strange error message when tried to update a record from a form

    Thanks goshoom , this fixed the issue. Can I ask about one more detail related to the same task, or it should maybe go to another question? When I update the Account Number field (through the dropdown list), the related field Account Name is not updated until the record is saved in the database. Is it possible to update the Account Name value before saving the record?

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 228,135 Most Valuable Professional on at
    RE: Strange error message when tried to update a record from a form

    Setting AllowEdit = No isn't sufficient. You need to override write() and validateWrite() methods of the data source. Write() shouldn't contain any code and validateWrite() should simply return true, without calling super().

  • Ascalab Profile Picture
    Ascalab 30 on at
    RE: Strange error message when tried to update a record from a Dynamics 365 F&O form

    My last sentence is not readable on the scree, as per what I can see. I wrote - It probably means that the update of MainAccount table is attempted, but how I can prevent it?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,277 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,135 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans