clearGlobalNotification (客户端 API 参考)

清除应用中的通知。

Syntax

Xrm.App.clearGlobalNotification(uniqueId).then(successCallback, errorCallback);

参数

Name 类型 必选 Description
uniqueId String 是的 用于清除使用 addGlobalNotification 设置的特定通知的 ID。
successCallback 功能 清除通知时要调用的函数。
errorCallback 功能 作失败时要调用的函数。

返回值

成功后,返回 promise 对象。

例子

以下示例演示如何添加通知,然后在 5 秒后自动关闭通知。

// define notification object
var notification = 
{
  type: 2,
  level: 3, //warning
  message: "Test warning notification"
}

Xrm.App.addGlobalNotification(notification).then(
    function success(result) {
        console.log("Notification created with ID: " + result);

    // Wait for 5 seconds and then clear the notification
    window.setTimeout(function () { 
            Xrm.App.clearGlobalNotification(result); }, 5000);
    },
    function (error) {
        console.log(error.message);
        // handle error conditions
    }
);

addGlobalNotification