web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Create a button in a RunBaseBatch through x++

(0) ShareShare
ReportReport
Posted on by 2,892

Hi, I need to add a button in a RunBaseBatch class that I have created, and assign it a clicked method, could you give me an example on how to do it? thanks!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    dolee Profile Picture
    11,279 on at
    RE: Create a button in a RunBaseBatch through x++

    Hi,

    Standard RunbaseBatch framework doesn't provide support for adding a button or click method.

    If you can present the options in a combobox drop down instead, it is possible to override the modified method of the combobox control to achieve similar results.

    Here's an example: devexpp.blogspot.hk/.../dynamics-ax-custom-lookup-in-dialog.html

  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Create a button in a RunBaseBatch through x++

    Instead of a simple button with clicked(), use a menu item button. You can add it to dialog by Dialog.addMenuItemButton().

    You'll find an example in BatchInfo.dialog().

  • saman0suke Profile Picture
    2,892 on at
    RE: Create a button in a RunBaseBatch through x++

    That's what I just did, however I need a way to pass it parameters, which I think is not possi ble through this way right? thanks!

  • Suggested answer
    Martin Dráb Profile Picture
    236,320 Most Valuable Professional on at
    RE: Create a button in a RunBaseBatch through x++

    You can easily get a reference to your batch class - and it's all what you need! All other parameters can be exposed by public methods of the class.

    It's as easy as this:

    DialogRunBase dialog = _args.caller();
    MyBatchClass myBatchClass = dialog.runBase();
    myBatchClass .parmMyParameter();
  • Suggested answer
    Matt Vail Profile Picture
    30 on at
    RE: Create a button in a RunBaseBatch through x++

    This can actually be done without a MenuItem (see below) but I would recommend isolating any logic in a class or to use the SysOperationFramework instead.

    Object dialog()
    {
        DialogGroup     mainGroup;
        DialogRunbase   dialog = super();
    
        FormBuildControl dialogGroupControl;
        FormBuildButtonControl myButton;
    
        mainGroup = dialog.addGroup("Group");
    
        dialogGroupControl = dialog.formBuildDesign().control(mainGroup.formBuildGroup().id());
        myButton= dialogGroupControl.addControl(FormControlType::Button,'MyButton');
        myButton.text("@SYS91539");
    
        return dialog;
    }
    
    public void dialogPostRun(DialogRunbase dialog)
    {
        super(dialog);
    
        dialog.formRun().controlMethodOverload(true);
        dialog.formRun().controlMethodOverloadObject(this);
    }
    
    public void MyButton_clicked()
    {
    
    }


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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans