Kvinnor sitter runt ett bord

Can you tell a joke? Not as good as Microsoft Dynamics 365 Business Central can do!

Some time ago I had the opportunity to work on a great project with an even greater client and team.  We were addressing one of the core client’s processes related to price management and procurement. Retail, list, agreed, purchase, sales, competitors…so many prices…and then there were the "marked for removal" issues related to the New Sales Experience feature in BC! But no, this is not a story about a feature that "ruins" everything!

Why was this project so special? Everyone worked hard, everyone was open-minded, curious...and we laughed a lot. We established an unwritten rule to spice up our meetings and writings with this and that - little funny stories, anecdotes, pictures... It was really good for all of us. But no, this isn't a story about team bonding either.

So, once we had done most of the complex pricing BC development, we started thinking about the challenges of change management and how to attract users to the system. A role center design was created, where key business figures would be in focus, along with charts and all common actions. And yet there is some room left for our unwritten rule - something fun.

I made a few suggestions to fill the space in the Role Center - some YouTube channels, images, some external company content…and finally a joke of the day.

Guess who won?!

Here it is - Business Central telling enough good jokes every day. When a user sees the numbers, why not brighten the day with a good joke?

The screenshot above is for demonstration purposes only with a focus on the "Joke of the day". It does not fully represent the actual key indicators or functions used.

So basically, what I needed was some role center widget and a good source of the jokes – or with simple words – googling. However, the biggest challenge is the quality of the joke. That remains at the disclaimer level – so this is not a story about that as well.

This joke site has been already provided an embedded script to be used and this great source helped me use this script in BC.

In short, there is a Widget table that contains HTML content in the Blob Type field. Users can access it via the Widget List page to get an option to save an embedded script, basically text to BC.

As there is no built-in support for displaying or controlling HTML content, we have to use the Control Add-in. A control Add-In is a special “object” where we define the look and feel of our custom content, the JavaScript that controls the object as well as its behavior when the user interacts with it. JavaScript functions will read and insert HTML code into BC ensuring the expected parsing of HTML elements – so instead of text we'll see widgets that come from an external source. Built-in widgets like Microsoft.Dynamics.Nav.Client.WebPageViewer can also be used, and I expect the results might be like this custom widget.

To invoke Control Add-In we use usercontrol and call the JavaScript functions with a little help from the TypeHelper object which will pass the correct html content from our blob.

Page Widget is added as a FactBox on the Widget List page so that the user can see a preview of the widget and make adjustments if needed. Similarly, there is a page prepared for Role Center that reads Widget Joke and displays it. A slightly different JavaScript function was used to place the HTML content in the correct position.

I know what you think – this should be a standard feature! Feel free to nominate on BC ideas.

Please note that there is no guarantee on the source of the Joke, as well as using this code with other widget and potentially playing with security!

For code behind please see GitHub.

PS. It took me some time to finish this article which I started in December 2021. Perhaps even more surprising is that Microsoft prolonged rolling out a new sales experience feature for Q2 2023!