Listen Insights Action executing event
Here's a Typescript example considering recordContext as the current browser tab's active record:
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'V1');
const tabContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext();
let recordContext: IRecordContext = await tabContext.getActiveRecord();
let insightContext: IInsightsContext = await recordContext.getInsightsContext();
const payload: IInsightsSubscriptionRequest = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnInsightsActionEvent') as IInsightsSubscriptionRequest;
payload.setId('insightsId1');
insightContext.subscribe(payload, (response: IEventResponse ) => {
const insightsActionEventResponse = response as IInsightsActionEventResponse;
console.log((insightsActionEventResponse.getResponseData() as IInsightsActionData).getInsightsId());
console.log((insightsActionEventResponse.getResponseData() as IInsightsActionData).getActionId());
console.log((insightsActionEventResponse.getResponseData() as IInsightsActionData).getActionName());
});
Here's a JavaScript example considering recordContext as current browser tabs active record:
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID', 'V1');
const tabContext = await frameworkProvider.getCurrentBrowserTabContext();
let recordContext = await tabContext.getActiveRecord();
let insightContext = await recordContext.getInsightsContext();
const payload = frameworkProvider.requestHelper.createSubscriptionRequest('cxEventBusOnInsightsActionEvent');
payload.setId('insightsId1');
insightContext.subscribe(payload, (response) => {
const insightsActionEventResponse = response;
console.log(insightsActionEventResponse.getResponseData().getInsightsId());
console.log(insightsActionEventResponse.getResponseData().getActionId());
console.log(insightsActionEventResponse.getResponseData().getActionName());
});