Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

Opening field specific data through menu item

Posted on by Microsoft Employee

Hi,

I have a form in which i have work order lines. in each of these lines I have purchase requisition id attached. i need to open a purchase requisition of the selected work order line through menu item button of purchase requisition. the problem i am facing is that when i click the button is opens the details of last entered purchase requisition, what i need is that i need that specific record of selected purchase requisition id.

Categories:
  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Opening field specific data through menu item

    No. The MenuItemButton will not open two forms if you don't call super(), which calls the default functionality.

    The bad thing about simple buttons is that they are not linked to AX security system. Menu item buttons are linked to privileges so you can control the security.

    Simple buttons are visible to anyone.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Opening field specific data through menu item

    Actually the difference is that we need to override the clicked() function of simple button and than assign function to it rather overriding the menuitem clicked() function because it opens two forms one for  menuFunction.run(args) and one for default functionality.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Opening field specific data through menu item

    That code should work exactly like my example - strange if it doesn't. But now I saw that in my code there is a typo, it calls the find method of PurchReqTable, but that method expects a RecId. You need to call findPurchReq method instead.

    If possible, try to put that code in the clicked method of the menuItemButton like I suggested. It will work there as well. Simple buttons are visible to anyone, whereas menuItemButtons respect the security system (privileges).

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Opening field specific data through menu item

    i found the solution. Thank you all for support

    make a simple button and override the click method

    void clicked()

    {

       Args args = new Args();

       MenuFunction menuFunction ;

       PurchReqTable   purchReqTableLocal;

       super();

       select purchReqTableLocal

       where purchReqTableLocal.PurchReqId == WorkOrderLines.PurchReqId;

       args.record(purchReqTableLocal);

       menuFunction = new MenuFunction(menuitemdisplaystr(PurchReqTableDetails), MenuItemType::Display);

       menuFunction.run(args);

    }

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Opening field specific data through menu item

    Well, then you need to do some changes on the form too.

    You could try manually setting (in code) the requisition id as a range for the query of the form's data source, if args.caller() was your form (work orders).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Opening field specific data through menu item

    I have done this but still the purchReqTable form is showing the last purchase requisition. Do i have to make any changes in that also?

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,148 on at
    RE: Opening field specific data through menu item

    Override the clicked method of the menu item button with something like this:

    void clicked()
    {
        Args args = new Args();
        MenuFunction menuFunction = this.menuFunction();
    
        args.record(PurchReqTable::find(WorkOrderLine.PurchReqId)); // I don't know the actual name of the table or field, so update it here
        args.caller(element);
        menuFunction.run(args);
    }


    That could work as it is, or require some fine tuning, since the init method of the PurchReqTable is quite complex. I didn't test it. But you get the idea.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,263 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,112 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans