Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Auto Fetch data based on RecId Relation

(0) ShareShare
ReportReport
Posted on by 46
i have two tables
Table1 ID,Name
Table 2 Address,Table1

Table1 field in Table2 Table is RefRecId and there is a foreign key relation between the two tables Table1.RecId = Table2.Table1

and i have a form has two datasources table1,table2

i wanna when i insert value in Table1 automatic relation works and fetch the recid from Table1 and put it in Table1 field in Table2 Table

when i create a record it create empty record in table2 with Table1 field is 0

i changed allowCreate proberty on table2 and override method create,write,written in table1 ,, and initvalue in table2 to put this code / table2.table1 = table1.recid /

but nothing works ,, i tried to override insert method of table1 and after super i put the same code ,, when i insert data in form two records inserted ,, the empty one and this one

my question is how to automatic link the two tables with recid relation or any relation how to auto fetch the data? any help pls ?
  • Suggested answer
    Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    Auto Fetch data based on RecId Relation
    I recommend using the solution I suggested before, but if you must add a data source by yourself, it's possible too. But then you must override two methods of your joined data source - validateWrite() and write(). Neither of them should call super(). validateWrite() should always return true and write() simply won't contain any code.
  • OmarAbdlhamed Profile Picture
    46 on at
    Auto Fetch data based on RecId Relation
    Hello martin,

    i will describe my issue clearly, the requirement to add some fields in Movement Journal form ,, instead of adding these fields in LedgerjournalTrans we made a new table with RecId relation with LedgerJournalTrans

    the Table LedgerJournalTransCustomization it has foreign key relation with LedgerJournalTrans 
    the fields in LedgerJournalTransCustomization is LedgerJournalTrans (recid) , some other fields

    we added the LedgerJournalTransCustomization table as a datasource in Movement journal form with link type outer join to LedgerJournalTrans table and added the new fields of LedgerJournalTransCustomization in the grid

    when i create a new record in ledgerjournaltrans it creates blank record in LedgerJournalTransCustomization

    my question is how to link them via the recid relation ? how to get Recid from ledgerjournaltrans and insert it into LedgerJournalTransCustomization to make the relation works
    i thought it will be automatically works from the screen but nothing happened ,, any help ?
  • Suggested answer
    Martin Dráb Profile Picture
    232,866 Most Valuable Professional on at
    Auto Fetch data based on RecId Relation
    Your description is confusing. Please try to use sentences, at least.
     
    Anyway, if I decrypted it correctly, the easier way is using a reference group (https://dev.goshoom.net/2014/09/replacement-groups-in-ax-2012/). Remove table1 data source from the form and drag Table2.Table1 field to the grid. If you've implemented the foreign key relation correctly, a reference group should be created automatically. If needed, change which field group is used by the control.

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,118 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans