addGlobalNotification (Client API reference)
Displays an error, information, warning, or success notification for an app, and lets you specify actions to execute based on the notification.
Syntax
Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);
Parameters
Name | Type | Required | Description |
---|---|---|---|
notification | Object | Yes | The notification to add. The object contains the following values:
|
successCallback | Function | No | A function to call when notification is displayed. A GUID value is passed to uniquely identify the notification. You can use the GUID value to close or dismiss the notification using the clearGlobalNotification method. |
errorCallback | Function | No | A function to call when the operation fails. |
Return Value
On success, returns a promise object containing a GUID value to uniquely identify the notification as described earlier in the description of the successCallback parameter.
Examples
Display an error notification that can't be closed or dismissed by user
// define notification object
var notification =
{
type: 2,
level: 2, //error
message: "Test error notification"
}
Xrm.App.addGlobalNotification(notification).then(
function success(result) {
console.log("Notification created with ID: " + result);
// perform other operations as required on notification display
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
This is how the error notification will appear in the app:
Display a warning notification that can be closed or dismissed by user
// define notification object
var notification =
{
type: 2,
level: 3, //warning
message: "Test warning notification",
showCloseButton: true
}
Xrm.App.addGlobalNotification(notification).then(
function success(result) {
console.log("Notification created with ID: " + result);
// perform other operations as required on notification display
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
This is how the warning notification will appear in the app:
Display an information notification with a "Learn more" link that can be clicked by users
// define action object
var myAction =
{
actionLabel: "Learn more",
eventHandler: function () {
Xrm.Navigation.openUrl("https://docs.microsoft.com/powerapps/");
// perform other operations as required on clicking
}
}
// define notification object
var notification =
{
type: 2,
level: 4, // information
message: "Test information notification",
action: myAction
}
Xrm.App.addGlobalNotification(notification).then(
function success(result) {
console.log("Notification created with ID: " + result);
// perform other operations as required on notification display
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
This is how the information notification will appear in the app:
See also
Feedback
Submit and view feedback for