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

Community site session details

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

Inserting Data into Two Tables at same time by using Code

(0) ShareShare
ReportReport
Posted on by 454

Hi,

I had created one field named Obsolete code in Invent table and BOM table . If i insert a data in the field obsolete code in invent table it should automatically inserted to the Obsoletecode field in BOM Table . I am new to ax .

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting Data into Two Tables at same time by using Code

    BOMTable is not directly related to InventTable. What is your actual requirement? Which BOMTable records should be updated, if one InventTable is updated?

    Would it be enough to have this field only in InventTable? And let your processes read it from there, instead of BOMTable?

    Anyway, you can hook in insert/update methods/events of InventTable, and write there some code to update any tables and fields.

  • Ram Kumar Profile Picture
    454 on at
    RE: Inserting Data into Two Tables at same time by using Code

    I newly created a field called Obsoletecode in Invent TAble and BOM Table also. If I enter a Obsolete code in Invent table (Newly inserting ) it should automatically inserted to the Obsolete code field in BOM Table .

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting Data into Two Tables at same time by using Code

    Yes, but on which BOMTable(s)?

    There are many InventTable records, and many BOMTable records, but they don't have any direct relation. So, let's assume your Obsoletecode item "ABC123" is now updated. Which BOMTable records are you going to update?

    Especially if you are talking about inserting of InventTable = creating a new record..

    Anyway, I think your original question is answered, I was just curious on what you want to achieve, and if there's a better way to achieve it.

  • Ram Kumar Profile Picture
    454 on at
    RE: Inserting Data into Two Tables at same time by using Code

    Hi Nikolaos for example if i am entering Obsolete code in invent table as "A1" for Item id "01", in BOM table also in the obsoletecode field "A1" should be entered for the same item id "01". If i am changing the obsolete code for that item id "01" as "B1" it should updated on the BOM table also . i need x++ code for that .

  • André Arnaud de Calavon Profile Picture
    299,349 Super User 2025 Season 2 on at
    RE: Inserting Data into Two Tables at same time by using Code

    Hi karthikeyanbalakrishnan,

    Can you also tell more about the process and the purpose to have these fields? If it is on the InventTable, what is the reason to duplicate this information?

    PS. I do think you intended to mention the table "BOM"?

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting Data into Two Tables at same time by using Code

    Before doing any development, I think it's good if you visualize to yourself what you want to achieve. Like I said, BOMTAble is not related to InventTable (there's no ItemId field in BOMTable). So you need to now define how you are going to find the correct BOMTables to update. Before that we don't need to think about x++ code. You only need to write code once you have described what it should do.

    Remember, a BOM can have many items. It can have 50 items, and all of them might have different ObsoleteCode. So perhaps you need to think a bit more about your requirement.

  • Ram Kumar Profile Picture
    454 on at
    RE: Inserting Data into Two Tables at same time by using Code

    Hi Nicholaos i said "BOM" Table not "BOMTABLE". Sorry .

  • Suggested answer
    nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Inserting Data into Two Tables at same time by using Code

    Ok, thanks for clarifying. I know you wrote "BOM Table" in your question but you also wrote "Invent table" so it was not clear if you mean BOMTable or BOM.

    Anyway, I recommend you not updating any field from InventTable to all related BOM records. Instead read this field directly from InventTable. We don't know what you want to achieve functionally, but whenever you have a BOM record in your process, you can find the related InventTable, using ItemId, and check the ObsoleteCode from there.

    Duplicating this information is not necessary, in fact it's not a very good idea. Let's imagine you have 100 000 BOM records for one item. Every time you update Obsoletecode for the item, the system now has to update 100 000 BOM records, too, slowing the system down.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,100

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 633 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans