清除應用程式中的通知。
語法
Xrm.App.clearGlobalNotification(uniqueId).then(successCallback, errorCallback);
參數
| 名稱 | 類型 | 為必填項目 | Description |
|---|---|---|---|
uniqueId |
繩子 | Yes | 用來清除使用 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
}
);