Add Notification method in Dynamics 365 forms - CloudFronts

Add Notification method in Dynamics 365 forms

Introduction:

In this blog, we are going to discuss the new feature of Dynamics 365 for form and field Notifications.

The new method basically provides similar functionality like recommendation action in Business Rule.

Method: addNotification

This method displays an error or recommendation notification for a control. Based on the notification option selected specify actions. On Dynamics 365 mobile clients, tapping on the icon will display the messages you specified and two standard buttons: Apply and Dismiss. Clicking Apply executes the action you define; clicking Dismiss closes the notification message.

Note: Setting an error notification on the control will block the saving of the form, setting a recommendation notification will not block the saving. By default, the notification level is set as ERROR if not specified.

Arguments:

  • Messages- (Array) The message that we want to display to user
  • Notification Level- (String) Specifies if we want to display error or recommendation
  • Unique ID- (String) Unique ID for notification
  • Actions-(Array of Objects) Corresponding actions for the message

Let’s implement a simple scenario. Based on the account type selected, the ticker symbol will be populated. If the account type is “Channel Partner User” than set the ticker symbol as “CPU”

We can create a web resource and use following code:

var AddTickerSymbolRecommendation = function () {
var typeOfAccount = Xrm.Page.getControl('xcd_typeofaccount');
var typeOfAccountValue = Xrm.Page.getAttribute('xcd_typeofaccount').getValue();
var tickerSymbol = Xrm.Page.data.entity.attributes.get('tickersymbol');
if (typeOfAccountValue == 1 && tickerSymbol.getValue() != "CPU") {
var actionsCol = {
message: 'Set the Ticker Symbol to CPU? ',
actions: null
};
actionsCol.actions = [function () {
tickerSymbol.setValue("CPU");
typeOfAccount.clearNotification("2002");
}];
typeOfAccount.addNotification({
messages: ["Set Ticker Symbol"],
notificationLevel: "RECOMMENDATION",
uniqueId: '2002',
actions: [actionsCol]
});
}
}

Bind this code on change of Account type field. When user selects Channel Partner User it will show an information icon like following:

When you click on the recommendation icon, you get a pop up to select Apply or Dismiss:

When you click Apply respective actions are performed:


Share Story :

Secured By miniOrange