# Passing data from Form to class via menu item

**URL:** <https://www.dynamicsuser.net/t/passing-data-from-form-to-class-via-menu-item/30050>\
**Category:** User Forum\
**Created:** [March 23, 2011, 3:54pm UTC](https://www.dynamicsuser.net/t/passing-data-from-form-to-class-via-menu-item/30050 "2011-03-23T15:54:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterjcm](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@peterjcm](https://www.dynamicsuser.net/u/peterjcm)\
**Post date:** [March 23, 2011, 3:54pm UTC](https://www.dynamicsuser.net/t/passing-data-from-form-to-class-via-menu-item/30050/1 "2011-03-23T15:54:29Z")

</div>

Hi,

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.

Thanks.

---

<div class="post-metadata">

**Author:** ![Daniel\_Volcov](https://avatars.discourse-cdn.com/v4/letter/d/f6c823/32.png) [@Daniel\_Volcov](https://www.dynamicsuser.net/u/Daniel_Volcov)\
**Post date:** [March 23, 2011, 4:08pm UTC](https://www.dynamicsuser.net/t/passing-data-from-form-to-class-via-menu-item/30050/2 "2011-03-23T16:08:34Z")

</div>

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.

regards

Daniel Volcov

---

<div class="post-metadata">

**Author:** ![peterjcm](https://avatars.discourse-cdn.com/v4/letter/p/34f0e0/32.png) [@peterjcm](https://www.dynamicsuser.net/u/peterjcm)\
**Post date:** [March 23, 2011, 8:30pm UTC](https://www.dynamicsuser.net/t/passing-data-from-form-to-class-via-menu-item/30050/3 "2011-03-23T20:30:51Z")

</div>

Thanks.

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.
