IContextResponse

The response object for events that provide information only about the context. For example, ContextCloseEvent subscription.

Functions

getResponseData

Use this function to get response data for Context-related event subscriptions.

Here's the syntax:
getResponseData(): IObjectContext;
The following code sample shows an example in Typescript for subscribing to the ContextClose event where the getResponseData method is used.
/// <reference path="uiEventsFramework.d.ts"/>
      const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
      const tabContext: ITabContext = await frameworkProvider.getTabContext();
      const requestObject: IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusContextCloseEvent');
      tabContext.subscribe(requestObject, (message: IEventResponse) => {
          const response = message as IContextResponse
          const context: IObjectContext = response.getResponseData();
          console.log(context.getObjectType());
          console.log(context.getObjectId());
          console.log(context.getTabId());
      });
  

The following code sample shows an example in JavaScript for subscribing to the ContextClose event where the getResponseData method is used.

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
      const tabContext = await frameworkProvider.getTabContext();
      const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusContextCloseEvent');
      tabContext.subscribe(requestObject, (response) => {
          const context = response.getResponseData();
          console.log(context.getObjectType());
          console.log(context.getObjectId());
          console.log(context.getTabId());
      });

getContext

Use this function to get the context of the response object.

Here's the syntax:
getContext(): IObjectContext;
The following code sample shows an example in Typescript for subscribing to the ContextClose event where the getContext method is used.
/// <reference path="uiEventsFramework.d.ts"/>
      const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');   
      const tabContext: ITabContext = await frameworkProvider.getTabContext();
      const requestObject: IEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusContextCloseEvent');
      tabContext.subscribe(requestObject, (response: IEventResponse) => {            
          console.log(response.getContext()); // usage of getContext
      }); 

The following code sample shows an example in JavaScript for subscribing to the ContextClose event where the getContext method is used.

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');   
      const tabContext = await frameworkProvider.getTabContext();
      const requestObject = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusContextCloseEvent')
      tabContext.subscribe(requestObject, (response) => {
          console.log(response.getContext()); // usage of getContext
      });