INotificationContext

INotificationContext enables you to do actions and events on Notifications.For example, show Notification, Close Notification, Listen to close notification, Listen to actions in notification.

To get the reference to NotificationContext use the getNotificationContext function.ds

Here's the syntax:
getNotificationContext(notificationId: string): Promise<INotificationContext>;
The following is a code sample in Typescript.
/// <reference path="uiEventsFramework.d.ts"/>
  const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
  const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId'); 
  
The following is a code sample in Javascript.
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
  const notificationContext = await frameworkProvider.getNotificationContext('notificationId'); 

Functions

subscribe

Use this function to listen to a SidePaneContext supported event.

The following sample shows the syntax:
subscribe: (requestObject: IEventRequest, callbackFunction: (response:IEventResponse) => void) => ISubscriptionContext; 
The following is a code sample in Typescript.
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
    let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007'); 
    const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent') as IEventRequest;
    notificationContext.subscribe(requestObject, (response) => {    
        const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
        console.log(resp.getResponseData().getNotificationId())     
    });
  
The following is a code sample in Javascript.
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1'); 
  let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
  const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent');
  notificationContext.subscribe(requestObject, (response) => {                  
      console.log(response.getResponseData().getNotificationId())     
  });

subscribeOnce

Use this function to listen once to a close event.

The following code sample shows the syntax:
subscribeOnce: (requestObject: IEventRequest, callbackFunction: (response:IEventResponse) => void) => ISubscriptionContext; 
The following is a code sample in Typescript:
//// <reference path="uiEventsFramework.d.ts"/> const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
    let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007'); 
    const requestObject:IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent') as IEventRequest;
    notificationContext.subscribeOnce(requestObject, (response) => {    
        const resp: INotificationCloseActionEventResponse = response as INotificationCloseActionEventResponse;
        console.log(resp.getResponseData().getNotificationId())     
    });
The following is a code sample in JavaScript:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1'); 
  let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
  const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnNotificationCloseActionEvent');
  notificationContext.subscribeOnce(requestObject, (response) => {                  
      console.log(response.getResponseData().getNotificationId())     
  });

publish

Use this function to publish a supported operation on the NotificationContext object.

The following code sample shows the syntax:
publish: (requestObject: IOperationRequest) => Promise<IOperationResponse>;
The following is a code sample in Typescript:
/// <reference path="uiEventsFramework.d.ts"/>     const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
     let notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
     const payload: IShowNotificationRequest = frameworkProvider.requestHelper.createPublishRequest('ShowNotification') as IShowNotificationRequest)  
     payload.setTitle(fieldName);
     payload.setSummary('Error message summary');
     notificationContext.publish(requestObject).then((message) => {
         const response: INotificationOperationResponse = message as INotificationOperationResponse;        
         //custom code 
     });
The following is a code sample in JavaScript:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');    
     let notificationContext = await frameworkProvider.getNotificationContext('notificationId007');
     const payload = frameworkProvider.requestHelper.createPublishRequest('ShowNotification');    
     payload.setTitle(fieldName);  
     payload.setSummary('error message summary ');
     notificationContext.publish(payload).then((response) => {
         // custom code
     }).catch((err) => {
         console.log(err);
     });

dispose

Use this function to remove all events subscribed on NotificationContext object.
dispose:() => void;
The following code sample shows an example in Typescript:
/// <reference path="uiEventsFramework.d.ts"/>
  const disposeSidePaneEvents = async () => {
  const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1'); 
  const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
  notificationContext.dispose();
  }   
The following code sample shows an example in JavaScript:
const disposeSidePaneEvents = async () => {
  const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');     
  const notificationContext = await frameworkProvider.getNotificationContext('notificationId007');     
  notificationContext.dispose();
  } 

getSupportedEvents

Use this function to get all the supported events on the NotificationContext object.

The following code sample shows the syntax:
getSupportedEvents(): string[];
The following code sample shows example in Typescript.
/// <reference path="uiEventsFramework.d.ts"/> 
  const getSupportedEvents = async () => {
  const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
  const sidePaneContext: ISidePaneContext = await uiEventsFrameworkInstance.getSidePaneContext('sidePaneId');
  const supportedEvents: string[] = sidePaneContext.getSupportedEvents();
  }  
The following code sample shows example in Javascript.
const getSupportedEvents = async () => {
      const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
      const sidePaneContext = await uiEventsFrameworkInstance.getSidePaneContext('sidePaneId');
     const 

getSupportedActions

Use this function to get all the supported actions on the NotificationContext object.

The following code sample shows the syntax:
getSupportedActions(): string[];
The following code sample shows example in Typescript.
/// <reference path="uiEventsFramework.d.ts"/> 
  const getSupportedActions = async () => {
  const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
  const notificationContext: INotificationContext = await frameworkProvider.getNotificationContext('notificationId007');
   const supportedActions: string[] = notificationContext.getSupportedActions();
  }    
The following code sample shows example for getSupportedActions in Javascript.
const getSupportedActions = async () => {
      const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('appname', 'v1');
      const notificationContext = await uiEventsFrameworkInstance.getNotificationContext('notificationId007');
     const