Passing data from Form to class via menu item


I’ve had a button on the SalesTable form running the clicked method to display an image from an archive ( outside of AX)

This works fine, but as Overriding the clicked method is not to best practice, I have changed the form to have a menuitem button which runs a class via a menuitem. However, I cant see a way of passing the current SalesTable record or just the SalesId through to the class. The class methods need this to select the appropriate image to display.


First thing, you need the correct type of menu Item to call this object.

A display menu item is to open up forms, an action menu item will execute a class and an output menu item is used for reports.

So after you place your action menu item in the form, you should point it to the class that you wish to run, and then you need to create a Main method in the class that you are pointing to. This method is the first to be executed when you call a class by a menu item, so it is static and must have the signature something like this

Static void myClassThatShowsPicture(Args args)

The args parameter will be automatically passed based on the current record that is sending this request to the class. If you place the menu item call in the SalesTable for instance , it will pass a SalesTable record in the args object and you shall be able to handle it in your class to execute your class.


Daniel Volcov


I’ve got it working now. I assumed that there would be a mechanism to pass to the menuitem and then from the menuitem to the class.

Thanks a lot.