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

Updating a lookup field on the form when related field is updated, but before submitting the changes to DB

(0) ShareShare
ReportReport
Posted on by 30

My main table (named for example MySetupTable) 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 read-only column in a form grid. I've done it by adding MainAccount table to the form's data sources, along with my main table, and specified the relation between the two data sources. Everything looks fine in there, but when the Account Number is updated in the grid (through a drop-down control), the Account Name is not updated until the record is saved in the database. My client would like to have the Account Name updated as soon as the value is changed on the form. I have tried to achieve this by overriding the modified method of the MainAccount field of the main table data source. And I have tried all of these, both separately and combined:
    MySetupTable_ds.refresh();
    MySetupTable_ds.research(true);
    MainAccount_ds.refresh();
    MainAccount_ds.research(true);
The only method that produced the result that I wanted (updated Main Account Name value right after the Account Number is updated) was MySetupTable_ds.research(true). But the problem with calling this method from the overridden update method is that it not only refreshes the data source, but also submits the changes to the database, which is not a desired behavior I suppose. So my question is - is it possible, and if it is how, to have the lookup field on the form (Account Name in this case) updated based on the selection in the related field (Account Code)?

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

    According to your previous thread, this question is about F&O, threfore let me move it to the Dynamics 365 Finance forum.

    Didn't you consider simply finding the name and setting it to the field in modified()?

  • Ascalab Profile Picture
    30 on at

    Thanks goshoom, I was thinking about that, but then I found an easier and I would say more elegant solution, which didn't require any X++ code. So instead of adding another data source for MainAccount table and using its Name field to be added to the grid's field list, I have added SetupMainAccount from my main table (MySetupTable), and thereafter by setting the Replacement Field Group property of these grid fields to the MainAccount's field groups that show just the Account Number field (this is AutoIdentification group) and the Name field (Name field group). Both these groups exist in the original MainAccount table design, but if some table doesn't have an adequate group, it can be added through a table extension.

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 March Top 10 Community Leaders

These are the community rock stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 616

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 331 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans