Scenario
- On Business Central, for every customer, we have its longitudine and latitude;
- We want to show the customer position with Microsoft Bing Map inside a factbox ;

THE RECIPE
The recipe is pretty easy and consists in:
- A Microsoft Bing account.
- A control add-ins: the awesome feature of Microsoft Business Central.
- An Azure Function
- In this sample I am not using Azure Vault to store passwords and I just use settings.json, you should when in production environment ๐
THE BUSINESS CENTRAL EXTENSION
Sources here: https://github.com/avalonit/ExBcCustomerMap
(UPDATED for Business Central 16.1 and 16.2)
The Business Central extension consists mainly in the Control-Addin. This component allows to load an external website inside a page’s factbox.
There’re just a table extension extending the table Customer by adding latitude and logitude and a page extension extending the “Customer Card” and adding a factbox with the control add-in inside. When the factbox is shown the extension loads the control-add and every time the user changes the current record the extension updates the map with current customer location.

The control add-in manage the webview loaded inside the factbox and defines how business central and the webview interact with each other.
In StartupScript= is defined the javascript that is run when the control add in is loaded. In Script= is defined the javascript
The control addin basically defines the interface of the alv_mapscript.js javascript functions that are accessible from Business Central.

The javascript and business central may have a two way “chat”. You can define callbacks in the javascript function to invoke Business Central functions.
I noticed with some versions of Business Central that the ControlAddin javascripts aren’t load if the name of control add contains spaces. So I named it “ALVStreetViewerControlAddIn”, don’t even try to rename it to “ALV Street Viewer Control AddIn” or it will fail to load JavaScripts and you will completely run Business Central mad ๐
To have the solution running don’t forget to open the “AVL Map Setup” table with its Page, the page contains the Azure Function url as published in your azure subscription.

THE AZURE FUNCTION
Sources here: https://github.com/avalonit/AzBcBingMap
A simple Azure Function is just a container for the HTML map shown inside the business central factbox.
BingFunction.cs contains the azure function that returns the bing map to business central control add-in.

You can configure your bing key in your local.settings.json.

A SHORT VIDEO TO EXPLAIN HOW TO PUBLISH AZURE FUNCTION
LAST UPDATE
18th of April 2020
Hello,
I tried your solution, but i am not able to create azure function.
Could you please provide detailed steps ?
And which file do i have to use in your github url refarding azure function ?
LikeLike
BC16.1 and BC 16.2 have introduced some changes and maps as I implemented are not working , are you using one of this version? I’m fixing in these days by the way.
LikeLike
Yes. exactly !
I’ll wait for your update.
Could you please include detailed steps for azure function ? Did you implement them through Visual Studio ?
LikeLike