Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

how to call menu item action in class AX 2012

(1) ShareShare
ReportReport
Posted on by 10,280

Plz somebody tell me how to accomplish such an issue

*This post is locked for comments

  • Douglas Noel Profile Picture
    3,905 on at
    RE: how to call menu item action in class AX 2012

    Hi Iulian,

    you 'have' exactly the point. Like It!!!!!

    But 'this question' is some kind of playground. Think of themes like CIL generation, pCode generation ....

    Think MS has to do something here.

    regards

    Douglas

  • Iulian Cordobin Profile Picture
    8,201 on at
    RE: how to call menu item action in class AX 2012

    Hi Douglas,

    I completely agree with you - some of the areas, like this, can be improved from a documentation point of view, and my example (explicitly inserted) was just to show the proper way.

    As I think we can all say, from our dev. experience, that what the framework automatically enforces for actions triggered from UI by the user (like clicking a button using a Menu Item), will not be checked/enforced when calling the same programmatically. So, the answer would be that for sure the framework (going through the super() call like the one you are referring to) is doing more, but it's not a clear answer for sure.

  • Douglas Noel Profile Picture
    3,905 on at
    RE: how to call menu item action in class AX 2012

    Hi Julian,

    my concern about the security apply to the usage of such MenuFunctions without the additional call to '&& menuFuntion.checkAccessRights()'

    This will work for sure.

    I think the really most important unknown (to my knowledge) question is:

    Which code, for example, is executed on a MenuItemButton, attached to such an action MenuItem, in reality?

    Means: What does the super() call of the clicked method do exactly?

    Is it only the code from you or somethig more.

    Btw: The SystemClasses in Ax are the most undocumented one - belonging this kind of questions.

    Especially from X++ code: What is exactly (and how) checked facing security under which conditions. This information seems to be a little bit underdesigned.

    Maybe noone should it know.  

    regards

    Douglas

  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at
    RE: how to call menu item action in class AX 2012

    As Douglas was mentioning the possible security check would be the difference from calling the class directly.

       MenuFunction    menuFunction;

       Args            args = new Args();

       args.record(_arecord);

       menuFunction = new MenuFunction(menuitemActionStr(MenuItem), MenuItemType::Action);

       if (menuFunction && menuFunction.checkAccessRights())

       {

           menuFunction.run(args);

       }

  • Douglas Noel Profile Picture
    3,905 on at
    RE: how to call menu item action in class AX 2012

    Hi Codehunter,

    the link given by Sohaib, lists the way using instantiating a menuFunction und a run().

    But a Action MenuItem with a ObjectType of Class does (nearly) nothing else than calling the static main method on the assigned class.

    The call of a class using a menufunction is synchronus, so you can also call the main function of this class from your code, passing the same args as to the menufunction.

    Advantage of using the menufunction could be - I'm not sure - the security.

    Don't know if this is evaluated during a call via x++ code? But maybe....

    Never checked that.

    regards

    Douglas

  • Sohaib Cheema Profile Picture
    46,614 User Group Leader on at
    RE: how to call menu item action in class AX 2012

    if you want to call a menu item by x++ code, it should be irrespective of where you are calling I mean in a class or job or anywhere you have to write the code in same way

    dynamicsuser.net/.../255746.aspx

    note: I am not sure what you are trying to do by calling an action menu item inside a class, which seems little unusual

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 50

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Featured topics

Product updates

Dynamics 365 release plans