How to Call a Run base class from a Menu item in AOT?

Hello I have create a run base class which gives the following output!

6431.scu.jpg

Now I want to call this class using a Menu Item Button from a form… I have dragged the Class into the Action part of the Menuitems… I have created a menuitem button in the design part of form and opened a method called clicked… I am stuck here… how can i called the Class using this method Clicked? Or is there a better way to do so?

Here is the drop down of the form!

0602.clicked.jpg

Hi,

1.There are two ways to do this :

1A)…


static void OpenDisplayMenuItem()

{

Args args = new Args();

;

args.record(VendTable::find(“XYZ”));

new MenuFunction(MenuItemDisplayStr(VendTable),MenuItemType::Display).run(Args);

}

1B)…


static void OpenForm()

{

FormRun formRun;

Args args = new Args();

;

args.name(formstr(VendTable));

args.record(CustTable::find(“XYZ”));

formRun = ClassFactory.formRunClass(args);

formRun.init();

formRun.run();

formRun.wait();

}

In case of any issue do let me know :slight_smile:

Regards

Pawan

No, both suggestions are wrong. There is no need to write any code to open a form by menu item. But above all, the question is about executing a RunBase class, not about a form.

@Chitanya, your problem is not primarily about RunBase classes, the problem is that you don’t know how menu items work in general.

If you use a menu item pointing to a class, AX executes its main(Args _args) method (or throw an error if it doesn’t exist). You have to implement your code in the main() method.

The usual implementation looks like this:

public static void main(Args _args)
{
    RunBase runBase = new MyClassExtendingRunBase();
    if (runBase.prompt())
    {
        runBase.run();
    }
}

As you see, you don’t need any clicked() method in your form. As soon as you implement the class correctly, you can drag & drop the menu item to forms and it all works.

Thanks Martin,

That worked!This is the first time i am working with classes and menu items so i got the concept wrong… thanks for helping me out! I got the Main method right but messed up at the properties in the menu items… Thanks anyways

5504.demo.jpg

Thanks for the Reply Pawan!