Open Address in Google Maps with Right-Click in D365FO

Open Addresses in Google Maps with Two Clicks

When you access customer or vendor details in Dynamics 365 for Finance and Operations (D365FO), their addresses are listed like this: “456 Peach Road, San Diego, CA 92114, USA”. This is great if you're familiar with San Diego, but if you're in Europe, for example, it might not be very helpful. You might wonder: Is the address in the city center or the outskirts? Normally, you'd have to copy the address and look it up on a map like Google Maps or Bing Maps. But what if you could search for the address directly from D365FO with just the right-click, using the context menu on the address field? This article describes how easily this can be achieved with a minor modification any developer can do in minutes.

The Problem

You can solve this problem with the D365FO standard customization. This involves adding new context menu items by overriding the getContextMenuOptions() and selectedMenuOption() methods for each form control.

This approach works fine if you only need to add a context menu item for a specific element in a specific form. But if you want this new context menu item to be available across the entire D365FO, you'll need to create a lot of extensions. Honestly, this isn't something you can knock out during a lunch break.

The Solution: Docentric Context Menu framework

With Docentric AX version 3.4.7, a new Context Menu framework was introduced. This framework allows you to easily add custom menu options to the D365FO context menus. Unlike the standard method where you need to override methods for each form element, the Docentric framework lets you do it with less hassle.

We've already used this framework to add a menu item to the context menu that allows you to Create Alerts in a ⚡Single Click in D365FO on any form or field. The feature is part of the Docentric AX Free Edition, and you're welcome to give it a try.

How Docentric Context Menu framework works

The Docentric framework offers a more streamlined approach compared to the standard D365FO implementation. Here’s a quick breakdown of how it works:

  • DocContextMenuManager class:
    • Subscribes to the onFormRunCompleted delegate of the FormRun object.
    • Calls the static process() method to create a new instance of DocContextMenuManager and starts processing additional context menu options.
  • DocContextMenuDefinitionBase class:
    • An abstract base class containing all the necessary methods for your custom context menu.
    • Simplifies the implementation process for adding custom menu options.

To illustrate, we'll show you how to add a custom context menu option to open an address from D365FO in Google Maps.

  

Steps to add your Context Menu Option

1. Define your Context Menu class

Create a class that inherits from DocContextMenuDefinitionBase. This is where you define your new context menu option.

2. Add Menu Option methods

Implement methods to enable the menu option, add it to the context menu, and specify which form controls it applies to.

3. Define Menu Option action

Implement the selectedMenuOption() method to specify what happens when the context menu option is clicked.

The Result

Here's the complete class you can copy to your environment and try it out.

Final Thoughts

Developers can easily add context menus to all form controls in D365FO using the Docentric AX framework. The simplest way is to find a type to which you want to apply the context menu.

Keep in mind, the framework isn't all-powerful 😜, so there are a few limitations worth mentioning, which you normally won't notice:

  • If a custom context menu option is already added to a form control at design time, your custom context menu option added through the Docentric AX framework won't be visible.
  • Custom context menu options can't be added to form controls for which a context menu is already defined using registerOverrideMethod() in a form extension.
  • Controls added at runtime also can't have custom context menu items.
The framework is available in the Docentric AX Free Edition. Give it a try and see how it can simplify your custom context menu implementations.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Docentric respects your privacy. Learn how your comment data is processed >>

Docentric respects your privacy. Learn how your comment data is processed >>