Skip to main content

Notifications

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.

  • learner.d365 Profile Picture
    learner.d365 35 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    InventTable having display method - Inventlocationid () can we use that method for filling myinventlocationId field through event handler.

    Can suggest me which event handler will I use for this?

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    First create the extension to add a new field.

    Then create new class and copy the oninserted eventhandler and copy the onupdated eventhandler decoration to the same method. Then write code to get the value which you require using some select statement.

    To get the value you need to go to those tables and find the relations and get the value.

    But this only works for new records as I said or updating a record/records but doesnt work for earlier records.

    I hope the same answer I said you earlier.

    Then build sync.

  • learner.d365 Profile Picture
    learner.d365 35 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    Requirement:

    Add a new field that is named MyInventLocationId to the InventTable table through extension. implement the logic of filling the new field through event handler.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    Unique Index in InventSum is on fields ItemId and InventDimId. There will be multiple records in InventSum for same ItemId, so you can't use InventSum just be ItemId.

    If you can provide exact requirement (not pointing to tables and also not referring that you need value in myInventLocationId field) like from where are you expecting InventLocationId (Warehouse) to be filled in your custom field then we can help you. I understand its a practice task for you but If its not clear to you then I suggest to please clarify the requirement.

  • learner.d365 Profile Picture
    learner.d365 35 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    InventTable and InventSum those both tables having common ItemId.

    InventSum table having Inventlocationid

    Can we fill myinventlocationId field with Inventlocationid through these two tables using event handlers

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    learner.d365 Any updates? Do you still need any help in your requirement.

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    Exactly this is what I want to understand. In this case, as the field is table level, as Mohit suggested write the runnable job code to populate the new field. Then all the db records will have values for new field. Then if they add a new record, then you have to use either event handlers or COC to populate the values like we have to write code for insert and update.

    For getting exact buffer or relation you can go to the InventTable and check all the method like you may find some kind of find method() which will help you.

    For assignment this design is okay. But if you get the same requirement then one problem arises if it is in real time scenario.

  • Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    In that case, you need to add logic in event handlers for new records. To update existing records, You can create a runnable class and execute directly from URL

    community.dynamics.com/.../running-runnable-class-through-url-in-dynamics-365-for-operations

  • learner.d365 Profile Picture
    learner.d365 35 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    InventTable alredy consists no of records we are adding one new field myinventlocationId to inventtable through extension. I need to implement the logic for filling new field (of old records in database) with inventlocationid through event handler.

    Actually this is a practice task for me but I'm unable to getting exact solution.

    I'm using legal entity - USMF

    Inventlocationid means Wearhouse like 11,21,23...

  • Bharani Preetham Peraka Profile Picture
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    RE: Implement the logic to fill new field "myinventlocationId" in Inventtable with inventlocationid in inventLocation table through event handler

    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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans