Recently I had the honor to give a Hands On workshop on Client Extensibility for Dynamics NAV 2013 at the Airlift event in Leipzig / Germany.
I thought I create a new workshop with a new AddIn – A Bing Map showing a customer on a map, including Geocoding. The presentation and workshop files are available for download here:
- Step by Step Presentation: Download here
- Workshop files for all steps: Download here
- AddIn registration tools for Dynamics NAV 2013: Download here
In order to go through the workshop you need to have
- Dynamics NAV 2013 installed
- your Developer License loaded into the NAV system
- Visual Studio 2012 Professional installed
- my Visual Studio Templates for NAV 2013 installed
- the AddIn Registration toolkit for NAV 2013 added to your data base and the assembly placed in the Client AddIns directory
- the Bing Map Control SDK installed
You will also need to request your self a developer key in order to use the Bing Map API, which you can do starting from the Bing Maps Developer Portal.
The Workshop is build in 6 steps (please excuse some German terms in the slides below):
- It starts with creating a basic AddIn using the Visual Studio templates and adds the Map WPF control and shows a Map part in the Windows Client.
- Then it adds server side controlled authentication, in order to set the Bing Map Key. This is done using a custom interface method.
- This step adds the capability to position the map, zoom in and out problematically and control the view. In this step a serializable .Net object is introduces that is passed for the location as a parameter
- Now we add a layer for pushpins and set a pushpin for a customer. We introduce client side geocoding here.
- In this step geocoding is moved server side and the position is requested first time a customer shall be located on a map. Th elocation is stored in the customer table.
- Finally we introduce the concept of asynchronous geocoding on the server. Such that the response of a geocoding request is not awaited and blocks the execution any longer. As soon as the asynchronous request returns, the customer location is updated in the database. The client is using the PingPong AddIn to poll for updates.
- The seventh steps is not included, but left for your own tinkering: Move the geocoding request into a code unit that is used in a Job Queue. This could allow automatic geocoding: for addresses where location is missing, but last geocoding did not return empty results or for addresses that have changed. With a job queue this can be then done behind the scenes, without involving the client.
(And this is of course the only good way to do geo coding, yet for the purpose of experimentation in the workshop I have implemented it in different tiers.)
How to just try out the final step:
- Copy all dlls from Workshop folder e.g. below for Step 6 in a subfolder (e.g BingMap) the Client AddIns directory :
“\Workshop\Step 6 (Serverside Async Geocoding)\MyBingMapAddIn\BingMapAddIn\bin\Debug\*.dll” =>
“C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Add-ins\BingMap\”
- Copy MyBingGeocoder.dll from Workshop folder e.g. below for Step 6 in a subfolder (e.g BingMap) the Server AddIns directory :
“\Workshop\Step 6 (Serverside Async Geocoding)\MyBingMapAddIn\BingMapAddIn\bin\Debug\MyBingGeocoder.dll” =>
“C:\Program Files\Microsoft Dynamics NAV\70\Service\Add-ins\BingMap\”
- Register AddIn. You may use the AddIn toolkit in the resources directory for that.
Copy the AddInToolkit forlder into the Client AdIns folder:
“\Workshop\Reources\AddInToolkit\” => “C:\Program Files (x86)\Microsoft Dynamics NAV\70\RoleTailored Client\Add-ins\AddInToolkit\
Run the page 65006 “Client Add-in registration” from the objects in the fob file “AddInRegistrationTool-V7.fob”
Click on “Check AddIn Files” and wait until list is updated. Check then the “MyBingMapAddIn” in order to register it.
- Import / merge the objects from fob / text files:
Changes to table Customer. for Latitude,Longitude,IsGeoCoded,GeocodingFailed and trigger code to maintain those fields
Customer list:utilize BingMapPart with sub page link
optional: Customer card: show geolocation fields
- You may update the global Text constant “BingAppKey” in the “MyBingMapPart” with a key you have requested for yourself.
(The key contained will be disabled soon.)
- Run the customer page and makew shure the BingMap part is showing. While scrolling through the list addresses will be geocoded and the
selected customer shown on the map if address could be geocoded.
When address changes, location will b ereset and new geocoding will be issued, as soon as customer selected again.
Geocoding happens asynchronous. If geocoding is not possible maps zooms out to whole world.
I hope this workshop is somewhat helpful, inspiring, …
And please keep enjoying to develop cool extensions for Dynamics NAV !
Senior Program Manager
Microsoft Dynamics NAV