No items found.

Adding new feature to context menu for AOT objects in AX 2012

Instead of manual changing it in  Tools->Options form, we would like have a possibility to setup it when we right click over the project’s object in Projects window. This could be done in a few steps described below.

Create the class with the feature’s code. To make a solution bit a flexible let’s assume that updating the startup project will be first of several additional features.

Prior to creating class we will create the base enum for menu items:

ANG_ContextMenuItem with element UpdateStartupProject:

Now let’s create the class ANG_ContextMenu with method openStartupProject:

class ANG_ContextMenu

{

}

public static ANG_ContextMenu construct()

{

return new ANG_ContextMenu();

}

public static void main(Args _args)

{

ANG_ContextMenu contextMenu = ANG_ContextMenu::construct();

if (_args.parmEnumType() == enumNum(ANG_ContextMenuItem))

{

contextMenu.run(_args);

}

}

public void run(Args _args)

{

switch (_args.parmEnum())

{

case ANG_ContextMenuItem::UpdateStartupProject :

this.updateStartUpProject(_args);

break;

}

}

private void updateStartupProject(Args _args)

{

UserInfo userInfo;

UtilElementName startupProj;

SysContextMenu contextMenu;

TreeNode treeNode;

if (SysContextMenu::startedFrom(_args))

{

contextMenu = _args.parmObject();

treeNode = contextMenu.first();

startupProj = treeNode.treeNodeName();

update_recordSet userInfo

setting StartupProject = startupProj

where userInfo.id == curUserId();

}

}

Create the menu item ANG_UpdateStartupProject for the feature with the properties as is displayed below:

Add the menu item to SysContextMenu menu:

So now it could be visible in context menu:

In the SysContextMenu class we need to modify method verifyItem() to prevent running the feature for other types of AOT objects. We can achieve this by adding below code to the last switch clause in the method:

case menuitemActionStr(ANG_UpdateStartupProject):

if ( firstNode.handle() == classNum(ProjectNode) && //Only launch from project node

match(#pathProjects,firstNode.treeNodePath()))

{

return 1;

}

return 0;

So now we have a new menu item in context menu with possibility to add other usable features in a simple way.

Zobacz inne

OneLake: czyli jak uporządkować odwieczny chaos w danych

Czytaj artykuł
Text Link

Ręczne przetwarzanie zamówień sprzedażowych to strata czasu. Jak to zautomatyzować?

Czytaj artykuł
Text Link

Najlepszy system ERP na 2026 rok? Microsoft Dynamics 365 w rankingach Gartner Magic Quadrant

Czytaj artykuł
Text Link
Wróć do wszystkich

Porozmawiajmy o Twoim projekcie

Napisz, z czym przychodzisz: wdrożenie, migracja, rozwój systemu albo pytanie, na które szukasz odpowiedzi. Wracamy z konkretną propozycją następnego kroku, nie z prezentacją handlową.

Dziękujemy za wiadomość!
Oops! Something went wrong while submitting the form.
Microsoft AI Builder
Microsoft Copilot Studio
No items found.
No items found.
No items found.