Creating a toast notification in Dynamics 365 using JavaScript

Jared Johnson, 06 July 2020

I have seen a few comments here and there about how to create a toast notification using JavaScript. Toast notifications were introduced in the Unified Interface pop up for things like creating a record via quick create.

image

This is where the addGlobalNotification function comes in. If you read the linked Microsoft Docs page you will learn that this is for displaying the message bars at the page.

image

However, there is a clue in the parameter section, the description of the type attribute says: “type: Number. Defines the type of notification. Currently, only a value of 2 is supported, which displays a message bar at the top of the app.”

Only 2 is supported? Well let’s try it with a type value of 1:
image

We get our toast notification!

Checking the various features of the addGlobalNotification function, most of them work the same as a toast notification, the showing/hiding of the close button, this is always displayed so you cannot create an un-dismissible notification. It will also follow the users Toast Notification Display Time setting, so will disappear automatically after about 8 or 80 seconds depending on what is set.

Unfortunately, as the description suggests this does not appear to be supported currently, however addGlobalNotification has only been in General Availability since May, so It will likely become available later in the year.