Opening web pages from menu items in Dynamics AX

This post will show you how to open a web page from a menu item in the standard Microsoft Dynamics AX client. It includes a brief code sample with a step-by-step explanation of how to set up the menu item. Enterprise Portal is not required for this scenario.

class LaunchWebBrowser
{
URL url;
}

public static void main(Args _args)
{
LaunchWebBrowser launchWebBrowser;
;

if (_args && _args.menuItemType() == MenuItemType::Action)
{
if (_args.parm())
{
launchWebBrowser = LaunchWebBrowser::newLaunchWebBrowser(_args.parm());
launchWebBrowser.run();
}
else
{
error(strFmt("No URL specified in the '%1' MenuItem object's Parameters property.", _args.menuItemName()));
}
}
else
{
error("LaunchWebBrowser class must be invoked using a MenuItem object with ObjectType property = Class.");
}
}

public static launchWebBrowser newLaunchWebBrowser(URL _url)
{
LaunchWebBrowser launchWebBrowser;
;

launchWebBrowser = LaunchWebBrowser::construct();
launchWebBrowser.url(_url);

return launchWebBrowser;
}

public static LaunchWebBrowser construct()
{
;

return new LaunchWebBrowser();
}

public URL url(URL _url = '')
{
;
//Determines whether the specified parameter for the current method has the default value.
if (!prmIsdefault(_url))
{
url = _url;
}

return url;
}

public void run()
{
;

if (url)
{
infolog.urlLookup(url);
}
else
{
error("Cannot launch web browser because no URL has been specified.");
}
} 

Then after create a Action MenuItem with  properties :

Parameter — http://www.Google.com

Object Type — Class

Object — LaunchWebBrowser

Save it & open the MenuItem.

Advertisements

3 thoughts on “Opening web pages from menu items in Dynamics AX

      • I must moderate my complaint. If Visual Studio is not installed then i.e. launches and displays the url. However if it is installed then VS is initiated and the template is displayed as XML.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s