OnBeforeSmartAction Event
This event is currently supported in new SR details and contact pages. This event can be listened on the top of the record context. This event is controllable with a promise.
Here's a Typescript sample:
const onBeforeSASubReq: ISmartActionEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId(<smart action id>);
const onBeforeSmartActionSubscription = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
// resolve or reject
});
});
Here's a JavaScript sample:
const onBeforeSASubReq = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId(<smart action id>);
const onBeforeSmartActionSubscription = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
// resolve or reject
});
});
Code Samples
Here's a Typescript sample:
const frameworkProvider: IUiEventsFrameworkProvider = await window.CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext();
const recordContext: IRecordContext = await tabContext.getActiveRecord();
const onBeforeSASubReq: ISmartActionEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId('SDA-ComposeEmail-serviceRequests');
const onBeforeSmartActionSubscription = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
resolve(); // or reject() to stop executing the smart action
});
});
// onBeforeSmartActionSubscription.dispose() // this is to dispose the subscription
Here's a JavaScript sample:
const frameworkProvider = await window.CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext = await frameworkProvider.getCurrentBrowserTabContext();
const recordContext = await tabContext.getActiveRecord();
const onBeforeSASubReq = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId('SDA-ComposeEmail-serviceRequests');
const onBeforeSmartActionSubscription: ISubscriptionContext = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
resolve();
});
});
// onBeforeSmartActionSubscription.dispose() // this is to dispose the subscription
Here's another example:
const frameworkProvider: IUiEventsFrameworkProvider = await window.CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext: ITabContext = await frameworkProvider.getCurrentBrowserTabContext();
const recordContext: IRecordContext = await tabContext.getActiveRecord();
const onBeforeSASubReq: ISmartActionEventRequest = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId('SDA-CreateServiceRequest-contacts');
const onBeforeSmartActionSubscription = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
resolve(); // or reject() to stop executing the smart action
});
});
// onBeforeSmartActionSubscription.dispose() // this is to dispose the subscription
Here's a JavaScript sample:
const frameworkProvider = await window.CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const tabContext = await frameworkProvider.getCurrentBrowserTabContext();
const recordContext = await tabContext.getActiveRecord();
const onBeforeSASubReq = frameworkProvider.requestHelper.createSubscriptionRequest('OnBeforeSmartAction');
onBeforeSASubReq.setSmartActionId('SDA-CreateServiceRequest-contacts');
const onBeforeSmartActionSubscription = recordContext.subscribe(onBeforeSASubReq, (response) => {
return new Promise((resolve, reject) => {
resolve();
});
});
// onBeforeSmartActionSubscription.dispose() // this is to dispose the subscription