Comparteix via


clearGlobalNotification (referència de l'API de client)

Esborra una notificació a l'aplicació.

Sintaxi

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

Paràmetres

Nom Tipus Necessari Descripció
uniqueId String L'identificador que s'ha d'utilitzar per esborrar una notificació específica que s'ha definit mitjançant addGlobalNotification.
successCallback Function No Funció per trucar quan s'esborra la notificació.
errorCallback Function No Una funció per cridar quan l'operació falla.

Valor retornat

En cas d'èxit, retorna un objecte de promesa.

Exemples

L'exemple següent mostra com afegir una notificació i tancar-la automàticament al cap de 5 segons.

// 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