Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / How to addMenuItem in ...
Finance forum
Suggested answer

How to addMenuItem in X++ and show button instead of link ?

Posted on by 338
Hi guys,
 
When creating class (RunBase class), I'm adding a menuitem in my Dialog like this :
 
public Object dialog()
    {
        dialog = super();
         
        DialogGroup dialogGroup = dialog.addGroup('Upload file');
        FormBuildControl formBuildControl = dialog.formBuildDesign().control(dialogGroup.name());

        dialogJournalNameId = dialog.addField(ExtendedTypeStr(LedgerJournalNameId), /Ledger journal name/);        
        dialog.addMenuItemButton(MenuItemType::Action, /My_Template/);

        return dialog;
    }
 
 
After run, the addition menu item is displayed as a link. How to make it as a button instead ?
Thanks.
 
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,312 User Group Leader on at
    How to addMenuItem in X++ and show button instead of link ?
    Hi @Teevo,
     
    Try this :
    1 - Dialog method
    public Object dialog()
    {
        DialogRunbase           dialog;
        DialogGroup             dlgGroup;
        FormBuildGroupControl   buttonGroup;
        FormBuildButtonControl  buttonControl;
    
        dialog = super();
        dialog.caption("Dialog");
    
        dlgGroup        = dialog.addGroup('ButtonGroup');
        buttonGroup     = dialog.formBuildDesign().control(dlgGroup.formBuildGroup().id());
        buttonControl   = buttonGroup.addControl(FormControlType::Button, 'Button Name');
    
        buttonControl.registerOverrideMethod(methodStr(FormButtonControl, clicked),
                                             methodStr(YourClass, YourClickedMethod),
                                             this);
    
        return dialog;
    }
    2 - Clicked method
    private void YourClickedMethod(FormButtonControl _formButtonControl)
    {
        MenuFunction    menuFunction;
        menuFunction = new MenuFunction(menuitemActionStr(My_Template), MenuItemType::Action);
        menuFunction.run();
    }
    Best regards,
    Mohamed Amine MAHMOUDI
  • Teevo Profile Picture
    Teevo 338 on at
    How to addMenuItem in X++ and show button instead of link ?
    Hi Layan,
     
    Noted about your advice of using SysOperationFrameWork instead. 
    However may I know how should I still want to use RunBase ? 
     
    Issue is I'm not the original developer but assisting only hence I can't change the existing one and this is using RunBase. 
     
    Thanks.
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 3,081 Super User on at
    How to addMenuItem in X++ and show button instead of link ?
    Hi Teevo,

    I would advise to use sysOperationFramework instead of runBase.

    Maybe check if this link is helpful:
    https://ariste.info/en/2020/07/add-menu-item-sysoperation-dialog/

    if you still want to stick with runBase, I think you should be able to do somehow the same to make it appear as a button.

    Thanks,
    Layan Jweihan
    Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future.

Helpful resources

Quick Links

Upcoming TechTalk: Copilot Capabilities…

Review the Copilot features that are currently available in Dynamics 365 Finance…

Demystifying Copilot: Service Edition with Sundar Raghavan

Sundar answers more questions about Copilot for Service...

Dynamics 365 Business Central vs Finance and SCM

Take a look at the key differences between Business Central and…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,377 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 223,308 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,140

Featured topics

Product updates

Dynamics 365 release plans