addGlobalNotification (クライアント API 参照)
エラー、情報、警告、または成功通知をアプリに表示し、通知に基づいて実行するアクションを指定することができます。
構文
Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);
パラメーター
| 件名 | 型 | 必要な領域 | 内容 |
|---|---|---|---|
| notification | オブジェクト | あり | 追加する通知。 オブジェクトには、次の値が含まれています:
|
| successCallback | Function | 無効 | 通知が表示された場合に呼び出す関数です。 GUID 値は、通知を一意に識別するために渡されます。 GUID 値を使用し、clearGlobalNotification メソッドを使用して、通知を閉じるか無視することができます。 |
| errorCallback | Function | 無効 | 処理が失敗したときに呼び出す関数。 |
戻り値
成功時には、successCallback パラメーターの説明で前述したように、GUID 値を含む promise オブジェクトを返し、通知を一意に識別します。
例
ユーザーが閉じることも無視することもできないエラー通知を表示する
// 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://docs.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
}
);
以下のように、アプリに情報通知が表示されます。

関連項目
注意
ドキュメントの言語設定についてお聞かせください。 簡単な調査を行います。 (この調査は英語です)
この調査には約 7 分かかります。 個人データは収集されません (プライバシー ステートメント)。
フィードバック
フィードバックの送信と表示