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, ...
Answered

X++ Code to populate rec id field in one table using rec id field of another table?

(0) ShareShare
ReportReport
Posted on by

I have table1 and table 2 and they have the relation as follows:

          table2.RefRecIdfield == table1.RecId

I need to populate the RecId field using X++ Code. Can someone suggest the code?

I have the same question (0)
  • nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi,

    just remove one of the"=" symbols from your code and you're there.

  • Smoors Profile Picture
    on at

    " table2.RefRecIdfield == table1.RecId" this is the relation between the 2 tables. I need to populate the RecId field of table1 from RecId field of table2 , can you please suggest the code for that?

  • Verified answer
    Martin Dráb Profile Picture
    239,022 Most Valuable Professional on at

    Your relation shows something else that you say you need.

    You should populate RefRecIdField if Table2 with RecId of Table1.

    Your request to populate Table1.RecId field from Table2.RecId makes no sense. You can't assign RecId, you don't want the same RecId in both tables and the request completely ignores RefRecIdField.

    Create a record in Table1 - the system will populate RecId on insert. Then use this value in Table2.RefRecIdField.

  • Smoors Profile Picture
    on at

    Sorry, my bad i think the otherwise but yeah i need to populate the RefRecId of table2 with RecId of table1.

    Can you please suggest me the X++ code for the same?

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    My first reply really tells you the solution. If you need more detailed help, please share more details about your requirement. But if you already shared the actual requirement, then your initial question already contains the solution, just remove one '=' symbol and your code is ready. Well you need also a semicolon (;) in the end of the line.

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

    I see you've created a follow-up thread: How do i use the "InsertEntityToDataSource" method on parent table to populate the RefRecid of Child table using RecId of Parent table.

    Does it mean that we're done in this thread? Didn't you forget to mark verify the answer?

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

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

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans