web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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,160 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
    237,801 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,160 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
    237,801 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans