다음을 통해 공유


addGlobalNotification(클라이언트 API 참조)

앱에 대한 오류, 정보, 경고 또는 성공 알림을 표시하고 알림에 따라 실행할 작업을 지정할 수 있습니다.

Syntax

Xrm.App.addGlobalNotification(notification).then(successCallback, errorCallback);

매개 변수

이름 유형 필수 Description
notification Object Yes 추가할 알림입니다. 알림 매개 변수 참조
successCallback 기능 아니오 알림이 표시될 때 호출할 함수입니다. 알림을 고유하게 식별하기 위해 GUID 값이 전달됩니다. GUID 값을 사용하여 clearGlobalNotification 메서드를 사용하여 알림을 닫거나 해제할 수 있습니다.
errorCallback 기능 아니오 작업이 실패할 때 호출하는 함수입니다.

알림 속성

개체에는 다음 속성이 포함됩니다.

재산 유형 필수 Description
action Object 아니오 다음 속성이 있는 개체입니다.
- actionLabel(선택 사항) 문자열. 메시지의 작업에 대한 레이블입니다.
- eventHandler: (선택 사항) 함수 참조입니다. 작업 레이블을 클릭할 때 실행할 함수입니다.
level Number Yes 알림 수준을 정의합니다. 유효한 값은 다음과 같습니다.
1: 성공
2: 오류
3: 경고
4: 정보
message String Yes 알림에 표시할 메시지입니다.
showCloseButton Bool 아니오 사용자가 알림을 닫거나 해제할 수 있는지 여부를 나타냅니다. 이 매개 변수를 지정하지 않으면 사용자는 기본적으로 알림을 닫거나 해제할 수 없습니다.
type Number Yes 알림 유형을 정의합니다. 현재는 앱 맨 위에 메시지 표시줄을 표시하는 값 2만 지원됩니다.

반환 값

성공 시 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://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
    }
);

앱에 정보 알림이 표시되는 방법은 다음과 같습니다.

예제 정보 알림입니다.

clearGlobalNotification