Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Is it possible to move a category from one parent to another in Category Hierarchy through code?

Posted on by Microsoft Employee

For example, would it be possible to move commodity code "Test1" from "TESTSummCommCode" to TESTSummCommCode2"?

I looked into methods of EcoResCategory table but there doesn't seem to be a method that can be used for this. Update method doesn't work properly if I change the parent category of a commodity code. And the AddToHierarchy method throws a validation error that parent category cannot be changed. Has anyone tried to accomplish something like copying the commodity code record, deleting it from wrong parent category and adding it under the right parent category?

Category-Hierarchy.JPG

Apologies for posting this in AX 2012 forum even though the snapshot is from D365FO because this works quite similar in both versions but AX 2012 has more active user base.

Thank you for your time!

  • Suggested answer
    Deepak Agarwal Profile Picture
    Deepak Agarwal 148 on at
    RE: Is it possible to move a category from one parent to another in Category Hierarchy through code?

    I see. How about having another integration (maybe inward only) to get all categories in F&O first then get their relevant transactions.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Ludwig Reinhard Microsoft Employee on at
    RE: Is it possible to move a category from one parent to another in Category Hierarchy through code?

    Hi GNJ,

    Can you think about any other feasible integration option?

    I am asking because the categories are shared across companies and trying to code something might result in problems in other companies and/or modules.

    Rather than fixing the problem afterwards I wonder if there is something that you could do with your integrations and how they are initially created.

    Best regards,

    Ludwig

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Is it possible to move a category from one parent to another in Category Hierarchy through code?

    agarwal AX So I need to do this because the product records come through integration and they already have commodities codes on them. But the summary commodity codes/parent categories come through another integration. So some commodity codes may not have parent category when they get created and so they sit under some generic parent category. And when the actual parent category finally gets created, the related commodity codes need to move from generic to actual parent automatically after the actual parent categories are created via batch job. So that is the business need. Thanks!

  • Deepak Agarwal Profile Picture
    Deepak Agarwal 148 on at
    RE: Is it possible to move a category from one parent to another in Category Hierarchy through code?

    Hello,

    May I know whats the business needs to do this. Ideally, you should be able to delete a category and create the same in another header.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans