Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Getting an added Menu Item Button on an Extension to Work

(0) ShareShare
ReportReport
Posted on by 100

I've done an extension on a form. I've added a Menu Item Button. I can't add any methods in the extension, so I created a class for COC. Code snippet:

[ExtensionOf(formStr(InventItemPrice))]
final class InventItemPrice_Extension
{
private xFormRun element;

[FormControlEventHandler(formControlStr(InventItemPrice, BOMCostRoll), FormControlEventType::Clicked)]
public static void BOMCostRoll_OnClicked(FormControl sender, FormControlEventArgs e)
{
}

I copied the event handler for OnClicked and pasted it into the code, see above. When I right mouse click on OnClicked and select Find References, I get the above link. When I run the form and click on the Menu Item Button, I get No object specified on menu item. Why?

I very new to D365 X++, so please excuse my ignorance. I appreciate any help.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Getting an added Menu Item Button on an Extension to Work

    Nice to hear that it works now!

    One more hint - you should use Display menu item for opening forms, Action menu item to run classes and Output menu items to display reports. I think there's no technical obstacle in using the wrong menu item type, but it's intended to be used like this.

  • NoDozing2 Profile Picture
    NoDozing2 100 on at
    RE: Getting an added Menu Item Button on an Extension to Work

    I got it now. I was adding the menu item button within the design pane in the form. Adding a, action menu item into the project gives me the properties you mentioned. I'm past the error. I'm wanting to open a form, get some user input, get the results, etc. I appreciate your patience.

  • Verified answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Getting an added Menu Item Button on an Extension to Work

    As already mentioned, if you want to run a menu item with the button (which is the purpose of MenuItemButtons), you need to define Object in the propeties of your Menu item. Then drag this menu item to a button group on the form extension. It will work without any development on the form.

    Could you please tell us what you are trying to achieve?

  • NoDozing2 Profile Picture
    NoDozing2 100 on at
    RE: Getting an added Menu Item Button on an Extension to Work

    Again, I'm very new to D365 X++. When I pull up the properties for the menu item button, I don't see an object type nor object name property. I realize if I could do something like below, in form code, I won't get the message:

       [Control("MenuFunctionButton")]

       class menuItemButtonName

       {

           void clicked()

           {

           }

       }

    However, I can't view the form code in an Extension.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 231,409 Most Valuable Professional on at
    RE: Getting an added Menu Item Button on an Extension to Work

    If you just want to put some code into the Clicked event handler, you should use a regular button and not a menu item button.

    If you use a menu item button, you need to specify a menu item pointing to an object, such as a class or a form. Then you can put your code there. It's still possible to handle the Clicked event as well, though, if there is some extra logic that you want to execute in the calling form.

    What's the best approach depends on what exactly you're doing.

  • Suggested answer
    nmaenpaa Profile Picture
    nmaenpaa 101,156 on at
    RE: Getting an added Menu Item Button on an Extension to Work

    You don't need any code to run a menu item button.

    Your problem is (like the error message says) that you haven't specified any object on the menu item. You need to specify an object type (Form, Class, Report) and the object name that you want the menu item to run.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans