In Dynamics 365 For Finance and Operations, we can add favorites forms via the user interface to provide quick access to the list of forms, by clicking the star icon next to the form or (to the workspace name) in the navigation pane.
In this article i will share how we can add favorites forms by code, but before let’s know.
- How they are managed ?
Generally all favorites forms in Dynamics 365 For Finance and Operations are represented by their menu items, so our entry point is the Menu item name.
- Where they are stored ?
All menu navigation favorites forms are stored in ‘SysMenuNavigationFavoriteItemsTable’ which contain all favorite elements with their associated AOT menu items names and path.
- Quick scenario: Add « All assets » form into Favorites menu :
Now let’s add « All assets » as a favorite form.
public static void main(Args _args)
{
SysMenuNavigationUserItemsManager sysMenuNavigationDataProvider = SysMenuNavigationUserItemsManager::construct();
MenuItemName menuItemname = "EntAssetObjectTableAll";
MenuItemType menuItemType = 0;
SysMenuNavigationPath menuNavigationPath = "[\"mainmenu\",\"EntAsset\",\"ObjectsMenu\",\"EntAssetObjectTableAll\"]", path = "Asset management,Assets,All assets";
SysMenuNavigationFavoriteItemsTable::AddIfNotExist(menuItemName, menuItemType, menuNavigationPath, path);
}
{
SysMenuNavigationUserItemsManager sysMenuNavigationDataProvider = SysMenuNavigationUserItemsManager::construct();
MenuItemName menuItemname = "EntAssetObjectTableAll";
MenuItemType menuItemType = 0;
SysMenuNavigationPath menuNavigationPath = "[\"mainmenu\",\"EntAsset\",\"ObjectsMenu\",\"EntAssetObjectTableAll\"]", path = "Asset management,Assets,All assets";
SysMenuNavigationFavoriteItemsTable::AddIfNotExist(menuItemName, menuItemType, menuNavigationPath, path);
}
the code will create new record if not exist in the sys table and add « All assets » form into the user-defined favorites section.
Un commentaire sur “How to add favorites forms through X++ in D365FO”