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

Hurtownia Danych 2.0.

Bezpieczeństwo danych w Microsoft Fabric. Od dostępu do workspace po Row Level Security

Czytaj artykuł
Text Link
Dynamics 365 F&O

Microsoft Data Archive w D365 F&O: jak działa, jakie ma ograniczenia i kiedy się nie uruchomi

Czytaj artykuł
Text Link
Produkcja i łańcuch dostaw

System ERP dla produkcji na Dynamics 365 jako dźwignia marży

Czytaj artykuł
Text Link
Wróć do wszystkich

Szukasz partnera Microsoft? Porozmawiajmy o Twoim projekcie

Pracuj z zespołem, który zrealizował wdrożenia i projekty dla dziesiątek firm. Umów rozmowę wstępną i sprawdź:

Jak Dynamics 365 dopasować do procesów Twojej firmy, a nie odwrotnie

Które obszary warto zautomatyzować, żeby odzyskać czas i obniżyć koszty

Jak wygląda wdrożenie z Anegis krok po kroku: od analizy po wsparcie po starcie

Wybierz termin spotkania
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.