Modal Window Operations in Current Browser Tab Context

You can perform the Modal Window operation on Global Context, and browser Tab context. For the MCA floating toolbar window, to get the opener tabs Tab context, use getCurrentBrowserTabContext method. It returns opener tab context of MCA floating toolbar window.

Note: You can perform the window operation by getting the Tab context of the opener window of MCA floating tool bar window. If browser tab ID isn't given, the opener page context of MCA floating tool bar window will be the default tab context. If the opener browser tab is closed, the tab context is retrieved from another opened browser tab.

The following example shows the syntax for the getTabContext method:

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

OpenModal Action in Tab Context

Here's a TypeScript example:

const openModal = async () => {    
    const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const openerWindowContext: ITabContext = await uiEventsFrameworkInstance.getCurrentBrowserTabContext();    
    const requestObject: IOpenModalWindowRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('OpenModal') as IOpenModalWindowRequest;
    requestObject.setURL('https://www.wikipedia.org/');    
    requestObject.setId('modal1');  
    const response: IModalWindowOperationResponse = await openerWindowContext.publish(requestObject) as IModalWindowOperationResponse;   
    const id:string = response.getResponseData().getId();
}

Here's a JavaScript example:

const openModal = async () => {    
    const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const openerWindowContext = await uiEventsFrameworkInstance.getCurrentBrowserTabContext();    
    const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('OpenModal');
    requestObject.setURL('https://www.wikipedia.org/');    
    requestObject.setId('modal1');  
    const response = await openerWindowContext.publish(requestObject);   
    const id = response.getResponseData().getId();
}

OpenPopup Action in Tab Context of a Given TabId

Here's a TypeScript example:

const openModal = async () => {    
    const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext: ITabContext = await uiEventsFrameworkInstance.getCurrentBrowserTabContext('tabId');    
    const requestObject: IOpenModalWindowRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('OpenModal') as IOpenModalWindowRequest;
    requestObject.setURL('https://www.wikipedia.org/');    
    requestObject.setId('popup1');  
    const response: IModalWindowOperationResponse = await tabContext.publish(requestObject) as IModalWindowOperationResponse;   
    const id:string = response.getResponseData().getId();
}

Here's a JavaScript example:

const openModal = async () => {    
    const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext = await uiEventsFrameworkInstance.getCurrentBrowserTabContext('tabId');    
    const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('OpenModal');
    requestObject.setURL('https://www.wikipedia.org/');    
    requestObject.setId('popup1');  
    const response = await tabContext.publish(requestObject);   
    const id = response.getResponseData().getId();
}

OpenPopup action in Tab Context of given TabId and msiTabId

Here's a TypeScript example:

const closePopup = async () => {    
    const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext: ITabContext = await uiEventsFrameworkInstance.getTabContext('tabId','msiTabId');    
    const requestObject: IOpenModalWindowRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ClosePopup') as IOpenModalWindowRequest;  
    requestObject.setId('popup1');  
    const response: IModalWindowOperationResponse = await tabContext.publish(requestObject) as IModalWindowOperationResponse;   
    const id:string = response.getResponseData().getId();
}

Here's a JavaScript example:

const openPopup = async () => {    
    const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext = await uiEventsFrameworkInstance.getTabContext('tabId');    
    const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('OpenPopup');
    requestObject.setURL('https://www.wikipedia.org/');    
    requestObject.setId('popup1');  
    const response = await tabContext.publish(requestObject);   
    const id = response.getResponseData().getId();
}

ClosePopup action in Tab Context of given TabId and msiTabId

Here's a TypeScript example:

const closePopup = async () => {    
    const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext: ITabContext = await uiEventsFrameworkInstance.getTabContext('tabId','msiTabId');    
    const requestObject: IModalWindowRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ClosePopup') as IOpenModalWindowRequest;  
    requestObject.setId('popup1');  
    const response: IModalWindowOperationResponse = await tabContext.publish(requestObject) as IModalWindowOperationResponse;   
    const id:string = response.getResponseData().getId();
}

Here's a JavaScript example:

const closePopup = async () => {    
    const uiEventsFrameworkInstance = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('app', 'v1');    
    const tabContext = await uiEventsFrameworkInstance.getTabContext('tabId','msiTabId');    
    const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ClosePopup');   
    requestObject.setId('popup1');  
    const response = await tabContext.publish(requestObject);   
    const id = response.getResponseData().getId();
}