Publish Custom Event on RecordContext
const publishCustomEvent = async () => {
const frameworkProvider: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
const payload: ICustomEventRequest = frameworkProvider.requestHelper.createPublishRequest('CustomEvent') as ICustomEventRequest;
payload.setCustomEventName('customEventName');
payload.setEventPayload({ message: 'any data' });
const globalContext: IGlobalContext = await frameworkProvider.getGlobalContext();
globalContext.publish(payload).then((message: IOperationResponse) => {
const response: ICustomEventResponse = message as ICustomEventResponse;
console.log(response.getResponseData());
console.log(response.getResponseData().getData());
console.log(response.getResponseData().getCustomEventName());
}).catch((err) => {
console.log(err);
});
};
const publishCustomEvent = async () => {
const frameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID','V1');
const payload = frameworkProvider.requestHelper.createPublishRequest('CustomEvent');
payload.setCustomEventName('customEventName');
payload.setEventPayload({ message: 'any data' });
const globalContext = await frameworkProvider.getGlobalContext();
globalContext.publish(payload).then((message) => {
console.log(message.getResponseData());
console.log(message.getResponseData().getData());
console.log(message.getResponseData().getCustomEventName());
}).catch((err) => {
console.log(err);
});
};
The event subscription and publish enable you to define any new life cycle event on a record which isn't supported by UEF. A custom event subscription on a particular record context is notified only when a custom Event publish or a custom Event trigger from VB happens on that particular record context. No other record context subscriptions are notified. Similarly, a custom event subscription on a particular browser tab context will be notified only when a custom Event publish or a custom Event trigger from VB happens on that particular tab context. No other tab context subscriptions are notified.
This capability of custom event also enables External Application to External Application communication inside VB through UEF.