How to keep “Show in content area” when form is open by menuitem from code?

On few places in our application we open ListPage in content area. On the address line there is something like “Company/Module/Folder”. On that listpages are menuitems which calls class which create menuitem and open the new ListPage form like:

Args args = new Args();
str param = 'Something';
MenuFunction openProjects = new MenuFunction('ListPageName',MenuItemType::Display);

args.parm(param);
openProjects.run(args);

When it called like that the address degenerate to “Company/”

Normally the display of that path depends on property “IsDisplayedInContentArea=Yes” on menu but I do not know how to set this in code.

How to keep the location (at least when the same ListPage is just reopen with different parameters)?

I’ve seen this reported by one of my developers, but I wasn’t able to reproduce it. I showed her my code:

new MenuFunction('CustTableListPage', MenuItemType::Display).run(new Args());

and haven’t heard about it since then, so I assume it works now.

I even set a parameter and called the code through a menu item from another list page, to simulate your scenario as closely as possible, but to no avail. The problem doesn’t occur in my case.

Try to use menuitem which has different name than the form name.

I found it. The Form, Menuitem Action, Menuitem Display, and Class I use must have same name.

May be I should write small blog post about this.

Your conclusion is wrong, as far as I can say. I can show you a counterexample, where every single name is unique.

But I managed to reproduce the problem and the explanation is simple. It happens if the menu item doesn’t exist anywhere in the menu or it’s not set up to be used in the content area. How could AX show the menu path if none exists?

I also see this behavior when the callers args are used instead of creating new Args() like:

public static void main (Args _args) {

MenuFunction openProjects = new MenuFunction(‘ListPageName’,MenuItemType::Display);

_args.param(‘Something’);

openProjects.run(_args);

}