How to open AX 2012 form from intranet web page or external appContinue reading
Hi fellow Microsoft Dynamics AX coders!
Today we will try to solve problem of opening Dynamics AX 2012 form from intranet web page. And I believe that given solution is flexible enough to be easily extended for using not only with a web pages.
During googling for this issue I have not found a solution which would be 100% satisfactory to me. Using named pipe approach is great but what if Dynamics AX client is not started yet? On the other hand there is no such a problem when we try to simply call ax32.exe with proper parameters but every call will open another Dynamics AX client instance which can shortly lead to getting out of resources on a target machine. So I decided to join this two solutions into one.
What we need to open AX window from external app is:
- Link placed on a web page
- Small console app written to open new AX client or open only window if client is already running
- New URL protocol linked with our new app registered in Windows registry
- A couple of amendments done to SysStartupCmd class to accommodate opening of new window with parameters
Let's do some coding now.
How should link on a web look like?
mms – it is name of our new protocol, you can call it as you want as long it is consistent with windows registry
MMSStartupElementAction – it is a prefix, used in SysStartupCmd::constuct to call appropriate class
_ - special char between prefix and menu item path
\Menu&Items\Display\MMSSalesQuotationProjTableForEdit – menu item path
? – Special char between menu item path and given parameter
EMUK-00021 – unique record identification, it can be anything dependent on type of data available in external system, can be RecId or like in this example quotation ID.
Now is time to write small console app which will be dealing with opening AX windows
From args we have to remove URL protocol name to have only proper command which will be send to Dynamics AX. Next thing is to obtain pipe name to create proper client stream object. Name consists with three parts:
- Constant string: “Dynamics\Event\”
- Value which can be changed in (AX 2012): System Administrator\Setup\System parameters\Alerts\Drill-down target
- User SID
When trying to connect to pipe (client.Connect()) app is waiting maximum 1 second before TimeOut exception is thrown. In such a case program will try to call Ax32.exe (from location taken from app settings file). Please note that in order for parameters work properly there is need to add “-StartupCmd=” string on the beginning of the command.
If client is successfully connected to pipe app will simply send binary data to a Dynamics pipe.
Every app activity is logged to a text file which is very useful while debugging as usually it is very difficult to gather sufficient information for troubleshooting from non-technical users.
App setting file:
After coding app URL protocol can be registered in Windows registry
Under a HKEY_CLASSES_ROOT node build such a tree structure:
The most important node is command one. Value should consist full path to your app and %1 for parameters:
MMS node parameters values should be like this:
Now is the time to process command in AX and open a window
It does not matter if AX is called using both named pipe and ax32.exe as
SysStartupCmd::construct is called in every case.
I extended switch method adding my own prefix and a new class which extends SysStartupCmd class:
Class is really simple the only tricky element is how to open form in Dynamics AX having given path.
First of all TreeNode object must be created based on given path.
Let's prepare also Args object to pass parameters to form. Like record which should be opened:
And now the only thing that left is to use AOTrun method with args passed to open AX form:
The retail industry is still dealing with the effects of the pandemic that lasted almost three years. In addition to this, further global events are causing disruption to the supply chain or financial stability of many retailers globally. As the industry confronts new challenges shaped by economic and geopolitical factors, it also faces trends influenced by changing customer expectations and needs. Here are 5 developments and trends to watch.
An interactive, AI-powered support for sales, customer service, marketing, and supply chain - Microsoft Dynamics 365 Copilot leverages generative AI and natural language processing technology to perform simple, yet time-consuming daily tasks that workload employees but can be automated.
Every company management facing a system change wonders what steps should be taken to ensure that this change does not cause turbulence to its business. Identical dilemmas are faced by any IT company that provides services to implement a new system. I will focus on these dilemmas today.
Artificial intelligence (AI) and machine learning (ML) technologies are changing business every day - just as new tools and services are frequently emerging to expand their use cases. PwC estimates that the impact of these technologies on the global economy will add approximately $15.7 trillion to its value by 2030 (1).