Hi! I have received the following task: Create new module in Dynamics AX and assign image or logo to this module.
Let’s develop this task.
Module is created very easy:
This is all. The new module have been added. Reopen Dynamics AX application.
The new modules appears without image (to move module on the top position clicks the Microsoft Dynamics AX >View > Navigate Pane Options…):
Adding module logo is not so easy. Select the TestMenu menu in the AOT, click right mouse button and select Properties. There are two properties NoramlImage and NormalResource.
In the NormalImage property the file path to the logo could be specified. But if we create product for sell then we can not specify the exact file path because each Customer will have own path.
In the NormalResource property the image id could be specified. It is suitable for our requirements. Let’s add image in Dynamics AX:
The new image resource will be created:
But this resource doesn’t have the resource id or image id property. Even more in the NormalResource property only the resource id of standard image can be specified. Standard image could be review here AOT > Forms > SysImageResources.
Trick: we will use the NormalImage property and Logo_image_png resource.
Create the following static method:
static client void addImageToModule()
{
TreeNode treeNodeMenu;
;
treeNodeMenu = SysDictMenu::newMenuName(menustr(TestMenu)).parmTreeNode();
if (treeNodeMenu)
{
treeNodeMenu.AOTsetProperty(identifierstr(NormalImage), SysResource::getImagePath(resourcestr(Logo_image_png)));
treeNodeMenu.AOTsave();
}
}
Call this method in the \Classes\Application\startupPost method:
// No SYS code must exist in this method
// If you need the startup command, look in the class SysStartupCmd
void startupPost()
{
;
Class1::addImageToModule();
}
Reopen application.
All the best 😉
Create the following static method:
static client void addImageToModule()
Where this method can be created?