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, ...
Suggested Answer

Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

(0) ShareShare
ReportReport
Posted on by 35

I added one field "myinventlocationId" in InventTable. I need write logic for filling this filed by inventlocationid in Inventlocation using event handler. 

I think there is a relations between Inventtable - "ItemId" -inventtrans - "inventDimId" -inventDim - "InventlocationId" -Inventlocation

Can you please help me to fill this new myinventLocationid field in InventTable.

I have the same question (0)
  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    Hi, Please provide more information on your requirement.

    You can extend InventTable to add a new field. For mapping field, it can be done via event handlers or Chain of command.

  • learner.d365 Profile Picture
    35 on at

    Actually question is the requirement I extended invent table field added.

    Through Event handlers implement the logic of filling the new field. Which event handler and what logic we need to write in event handler is my question sir

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    You can use oninserted or oninserting event handler to write the logic. Once you copy paste that in new class just do a find reference and check how it is implemented in standard and use the same way to write the logic.

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    You can use onInserting event handler but I prefer to create a extension class for table and use CoC (Chain of command) on insert method

    Event Handler: rajusdynamics365ax.home.blog/.../

    CoC: dynamics365musings.com/.../

    For CoC, before next insert() statement, map your new field.

    If your requirement is to map field based on some conditions after inserting a record then onInserted event handler or after next insert() can be used.

  • learner.d365 Profile Picture
    35 on at

    Can you please reread the requirement and help me to solve this question

  • Suggested answer
    Mohit Rampal Profile Picture
    12,565 Moderator on at

    Your new requirement is not very clear, however to create InventLocationId in InventTable, you can leverage the code mentioned in this thread in pre-insert event handler and map value to myLocationId field.

    community.dynamics.com/.../how-to-find-inventlocationid-from-itemid-inventtable

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    Can you please provide more details? So that we can understand if it is through batch or realtime or just for that record or how is that?

  • learner.d365 Profile Picture
    35 on at

    I added one field "myinventlocationId" in InventTable through extension. I need write logic for filling this filed by inventlocationid using event handler.

    InventDim table having Inventlocationid.

    I need to get that field values into myinventlocationId through event handler.

    I facing issue to find which event handler I need to take and logic to fill field with inventlocationid.

  • Mohit Rampal Profile Picture
    12,565 Moderator on at

    InventDim can have multiple records with ItemId from InventTable. There is no direct relationship with InventDim and InventTable. If you can tell us about your business requirement then we might help you.

    I understood that you need to add value in your custom field 'myinventlocationId; in InventTable. However, what should be the value is still not clear and is it during creation of record in InventTable.

    If you need to insert Default location in InventTable, please check this article (Same code I shared before) and add in post event handler for insert method of InventTable.

    microsoft-dynamics-ax-erp.blogspot.com/.../how-to-get-item-default-inventory.html

  • Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at

    We understood your requirement that you need to add or populate the data to that new field. But my question is if you use event handler, only when inserting new record or updating a record only that change comes but not for records already in the db. So I am asking what is the exact requirement is it simply for one line or real time or how?  Please let us know requirement than you can ask your issue.

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 663 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 348 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans