הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
הצגת הודעת שגיאה, מידע, אזהרה או הצלחה עבור אפליקציה, ומאפשרת לך לציין פעולות לביצוע בהתבסס על ההודעה.
תחביר
Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);
Parameters
| שם | Type | נדרש | תיאור |
|---|---|---|---|
notification |
Object | כן | ההודעה להוספה. ראה פרמטר הודעה |
successCallback |
פונקציה | לא | פונקציה להתקשרות כאשר מוצגת הודעה. ערך GUID מועבר כדי לזהות באופן ייחודי את ההודעה. באפשרותך להשתמש בערך ה- GUID כדי לסגור או לבטל את ההודעה באמצעות פעולת השירות clearGlobalNotification. |
errorCallback |
פונקציה | לא | פונקציה שיש לקרוא לה כאשר הפעולה נכשלת. |
מאפיין הודעה
האובייקט מכיל את המאפיינים הבאים:
| Property | Type | נדרש | תיאור |
|---|---|---|---|
action |
Object | לא | אובייקט עם המאפיינים הבאים: - actionLabel(אופציונלי) מחרוזת. התווית עבור הפעולה בהודעה.- eventHandler: (אופציונלי) הפניה לפונקציה. הפונקציה לביצוע בעת לחיצה על תווית הפעולה. |
level |
מספר | כן | הגדרת רמת ההודעה. ערכים חוקיים הם: 1: הצלחה 2: שגיאה 3: אזהרה 4: מידע |
message |
String | כן | ההודעה שיוצגו בהודעה. |
showCloseButton |
בול | לא | מציין אם המשתמש יכול לסגור או לבטל את ההודעה. אם לא תציין פרמטר זה, המשתמשים לא יוכלו לסגור או לבטל את ההודעה כברירת מחדל. |
type |
מספר | כן | הגדרת סוג ההודעה. בשלב זה, רק ערך של 2 נתמך, המציג סרגל הודעות בחלק העליון של היישום. |
ערך החזרה
בעת הצלחה, החזרת אובייקט מבטיח המכיל ערך GUID כדי לזהות באופן ייחודי את ההודעה כפי שתואר קודם בתיאור של הפרמטר successCallback .
דוגמאות
הצג הודעת שגיאה שהמשתמש לא יכול לסגור או לבטל אותה
// 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
}
);
כך תופיע הודעת השגיאה באפליקציה:
הצג הודעת אזהרה שהמשתמש יכול לסגור או לבטל אותה
// 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
}
);
כך תופיע הודעת האזהרה באפליקציה:
הצגת הודעת מידע עם קישור "למידע נוסף" שמשתמשים יכולים ללחוץ עליו
// 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
}
);
כך תופיע הודעת המידע באפליקציה: