Agent Info Operation in Current Browser Tab Context

This action can be performed on a particular tab by getting the tab context of a tab by providing the browser tab ID. For MCA floating toolbar window, to get the opener tabs tab context, use the getCurrentBrowserTabContext method which returns opener tab context of MCA floating toolbar window.

All the functions in global context before detailed work with Tab Context.

The following example shows the syntax for the getTabContext method:

getCurrentBrowserTabContext(tabId?:string): Promise<ITabContext>;

Example Function with Current Browser TabContext

The following code sample shows an example in TypeScript for getting agent's first name using getFirstName method using opener windows tab context.

/// <reference path="uiEventsFramework.d.ts"/>   
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');      
const openerContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext();
const requestObject: IOperationRequest = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo') as CX_SVC_UI_EVENTS_FRAMEWORK.IOperationRequest;  
openerContext.publish(requestObject).then((message: IOperationResponse) => { 
 	const response: IGetAgentInfoResponse = message as IGetAgentInfoResponse;
	console.log(response.getFirstName()); // usage of getFirstName
});

The following code sample shows an example in JavaScript for getting agent's first name using getFirstName method.

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
const openerContext = await frameworkProvider.getCurrentBrowserTabContext();
const requestObject = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo'); openerContext.publish(requestObject).then((response) => {
	console.log(response.getFirstName());
});

Example function with Current Browser TabContext

All the Agent info functions will work with Tab Context.

The following code sample shows an example in TypeScript for getting agent's first name using getFirstName method using tab context of given tab Id.

/// <reference path="uiEventsFramework.d.ts"/>   
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');      
const tabContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext('tabId');
const requestObject: IOperationRequest = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo') as CX_SVC_UI_EVENTS_FRAMEWORK.IOperationRequest;  
tabContext.publish(requestObject).then((message: IOperationResponse) => { 
 	const response: IGetAgentInfoResponse = message as IGetAgentInfoResponse;
	console.log(response.getFirstName()); // usage of getFirstName
});

The following code sample shows an example in JavaScript for getting agent's first name using the getFirstName method.

const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID''v1');
const tabContext = await frameworkProvider.getCurrentBrowserTabContext('tabId');
const requestObject = frameworkProvider.requestHelper.createPublishRequest('GetAgentInfo'); tabContext.publish(requestObject).then((response) => {
	console.log(response.getFirstName());
});