With the latest Dynamics 365 for Finance and SCM 10.0.10 version, we’re getting a new feature that will allow us to add actions to the message bar, using the Messaging API like we used to do in AX2012 with the SysInfoAction class.

Remember this is in the latest preview version. You can access the preview versions joining the Dynamics 365 Insider Program.

Messaging API

The Messaging API allow us to show information to the users in the message bars, the Action center, or message boxes.

Message bar

We usually use the message bar to display information of synchronous tasks in the form we’re working on. It can be shown on dialogs and slider dialogs too.

Its purpose is to display information from the current form, so if you close the form the messages are gone!

Action center

The action center is used to display information of asynchronous tasks. The notifications will stay there until the user dismisses them.

You will see the amount of messages in the bell on the top right corner of MSDyn365FO. Remember that the maximum amount of messages that will be shown is 500. If you need to display more than 500 messages you might want to create some kind of log for your process instead of using the Action center notifications.

Message boxes

The message boxes will interrupt whatever the user is doing. It’s used for synchronous operations that have finished. It will block the UI until it’s closed.

Messaging API AddAction

This is something that has been missing since AX7 came out and has now been added to the Messaging API with the Message::addAction() method:

We need to pass the following parameters:

MessageSeverity _severity

An enum with with the values Informational, Warning and Error. It’s clear, the same as int the infolog class. Info (blue), Warning (yellow) and Error (red) message bars.

SysInfoLogStr _text

The text of the message we’re displaying. “An error ocurred”, “Validation failed”, whatever you want.

str _actionText

The clickable text of the action. This will be the link to a form (with a display menu item) or an action (with an action menu item).

MessageActionType _type

The type of the action, an enum with the values ActionMenuItem, DisplayMenuItem and ApplyViewQuery.

The display and action types are quite clear. About the ApplyViewQuery one: I’ve been looking in the code for this action and the only place where I’ve found it’s being used is in the rolloutView method of FormRunConfigurationClass which is an internal method.

I’m not sure about this, but it’s probably being used to log failures in the telemetry when the configuration of a form is loaded. I’ve only found 1 reference to the enum in the metadata and it’s this class.

str _payload

The JSON payload is simply this:

You define a new action with a display or action menu item and serialize it. Done.

An example

Imagine you got a process that needs some parameters from the CustParameters table, you validate that the fields are filled in and if they aren’t you throw an error. Now you can add a link to the message like it’s done in the code above, and it’d look like this:

Messaging API with action
Messaging API with action

The user will have a quick way of going to the Customer Parameters form and complete the setup. This is specially useful to guide users to the right places.

Subscribe!

Receive an email when a new post is published

Write A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!