Nota
L'accés a aquesta pàgina requereix autorització. Pots provar d'iniciar sessió o canviar de directori.
L'accés a aquesta pàgina requereix autorització. Pots provar de canviar directoris.
Mostra una notificació d'error, informació, advertiment o èxit per a una aplicació i us permet especificar les accions que s'han d'executar en funció de la notificació.
Sintaxi
Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);
Paràmetres
| Nom | Tipus | Necessari | Descripció |
|---|---|---|---|
notification |
Objecte | Sí | La notificació per afegir. Veure paràmetre de notificació |
successCallback |
Function | No | Funció per trucar quan es mostra una notificació. Es passa un valor GUID per identificar de manera única la notificació. Podeu utilitzar el valor GUID per tancar o descartar la notificació mitjançant el mètode clearGlobalNotification. |
errorCallback |
Function | No | Una funció per cridar quan l'operació falla. |
Propietat de notificació
L'objecte conté les propietats següents:
| Propietat | Tipus | Necessari | Descripció |
|---|---|---|---|
action |
Objecte | No | Un objecte amb les propietats següents: - actionLabel(Opcional) Corda. L'etiqueta de l'acció del missatge.- eventHandler: (Opcional) Referència de la funció. La funció que s'executarà quan es fa clic a l'etiqueta d'acció. |
level |
Nombre | Sí | Defineix el nivell de notificació. Els valors vàlids són: 1: Èxit 2: Error 3: Avís 4: Informació |
message |
String | Sí | El missatge que es mostrarà a la notificació. |
showCloseButton |
Bool | No | Indica si l'usuari pot tancar o descartar la notificació. Si no especifiqueu aquest paràmetre, els usuaris no podran tancar ni descartar la notificació per defecte. |
type |
Nombre | Sí | Defineix el tipus de notificació. Actualment, només s'admet un valor de 2, que mostra una barra de missatges a la part superior de l'aplicació. |
Valor de retorn
En cas d'èxit, retorna un objecte de promesa que conté un valor GUID per identificar de manera única la notificació tal com s'ha descrit anteriorment a la descripció del paràmetre successCallback .
Exemples
Mostrar una notificació d'error que l'usuari no pot tancar ni descartar
// 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
}
);
Així apareixerà la notificació d'error a l'aplicació:
Mostra una notificació d'advertiment que l'usuari pot tancar o descartar
// 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
}
);
Així apareixerà la notificació d'avís a l'aplicació:
Mostrar una notificació d'informació amb un enllaç "Més informació" en què els usuaris poden fer clic
// define action object
var myAction =
{
actionLabel: "Learn more",
eventHandler: function () {
Xrm.Navigation.openUrl("https://learn.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
}
);
Així apareixerà la notificació d'informació a l'aplicació: