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 :
Finance | Project Operations, Human Resources, ...
Answered

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

(0) ShareShare
ReportReport
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?

I have the same question (0)
  • Ascalab Profile Picture
    30 on at

    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?

  • Verified answer
    Martin Dráb Profile Picture
    240,521 Most Valuable Professional on at

    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
    30 on at

    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?

  • Martin Dráb Profile Picture
    240,521 Most Valuable Professional on at

    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
    30 on at

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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
SajeedMullaji Profile Picture

SajeedMullaji 760

#2
Martin Dráb Profile Picture

Martin Dráb 330 Most Valuable Professional

#3
CU10121822-0 Profile Picture

CU10121822-0 310

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans