The Outlook add-in in Business Central – Document Viewer

In my previous post:
Customize the Outlook add-in in Business Central – Discover Microsoft Business Central (bertverbeek.nl)
We had a deeper look into the Contact Insights add-in for Outlook. But there is another add-in for Outlook from Business Central. This add-in has the name “Document Viewer”.
Using Business Central with Outlook – Business Central | Microsoft Learn
With the “Document Viewer” the add-in highlights text inside your e-mail and if you click on the hyperlink it will open Business Central in a pop-up window and opens (if you have the right number) the document in Business Central:

But how works it technically and can you create your own “Document Viewer” add-in?
The manifest file
If we look at the manifest file the first part is totally the same as the “Contact Insights” add-in. So no need to talk about that. That is already explained here:
Customize the Outlook add-in in Business Central – Discover Microsoft Business Central (bertverbeek.nl)
If you look a little deeper you can see in the RuleCollection part that is uses regular expression for collecting the words:

(IFA|IOF|IOR|IFC|IFC|ME|SO)([A-Za-z0-9]+)|(invoice|order|quote|credit memo|Purchase Header|Purchase Header|Purchase Header|Purchase Header|Service Call|Service Order):? ?#?([\w_/\#\*\+\\\|-]*[0-9]+)
I’m not a Regular Expression guru. But here you can see at grabs all the number series that are important and the words.
NB: If you want to learn more about Regular Expression then 20 March 2023 there will be a webinar on Areopa (Registration (gotowebinar.com)) by David Feldhoff | LinkedIn
(recordings are shared here: Areopa webinars – YouTube)
Business central Codeunit
After the manifest you have to create a codeunit with some events. The events are all the same as the “Contact Insights”. The event ‘OnGetExternalHandlerCodeunit’ is a little bit difference:

Here is the hosttype ‘Outlook-hyperlink’
Then in the OnRun() trigger of the codeunit we put the function to handle the document:

In the function RedirectToDocuments it first collect the documents and inserts it in a temp table “Office Document Selection” then it opens Business Central:

The collection of the documents will be in two ways. First it try to find by serie number:


As you can see it uses also here Regular Expression. After he found something in the table (with function SetDocumentMatchRecord) he inserts a record into the temp table “Office Document Selection”:

When something is found he will open the document in Business Central:

So in this way you can handle your own “Document Viewer” add-in!
The code example you can find here:
Bertverbeek4PS/OutlookAddin (github.com)
Leave a Reply