ExecuteSmartAction Operation

This is a command used to create the Smart Action publish request object. This request object is the set with the proper Smart Action ID to be executed. This can be published over recordContext or tabContext.

Syntax

Here's a Typescript sample:

const tabContext: ITabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext();
const recordContext: IRecordContext =  tabContext.getActiveRecord();  

// Get smartActionContext from tab context or record context (use one of the following)
let smartActionContext: IsmartActionContext = await tabContext.getSmartActionContext();
let smartActionContext: IsmartActionContext = await recordContext.getSmartActionContext();

// Create publish request object
const requestObject: IExecuteSmartActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');

// set the proper smart action id (see section 'How to get the smart action id ?' for more details)
requestObject.setId(<SmartActionId>);

smartActionContext.publish(requestObject).then((response: ISmartActionOperationResponse) => {

  console.log((response.getResponseData() as ISMartActionOperationResponseData).getId());
});
Here's a JavaScript sample:
const tabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext();
const recordContext =  tabContext.getActiveRecord();  

// Get smartActionContext from tab context or record context (use one of the following)
let smartActionContext = await tabContext.getSmartActionContext();
let smartActionContext = await recordContext.getSmartActionContext();

// Create publish request object
const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');

// set the proper smart action id (see section 'How to get the smart action id ?' for more details)
requestObject.setId(<SmartActionId>);

smartActionContext.publish(requestObject).then((response) => {

  console.log(response.getResponseData().getId());
});

Publish ExecuteSmartAction operation for Log-A-Call Smart Action from RecordContext of Contact

Here's an example of how use executeSmartAction from a Contact Page (the ID is ActionId from Smart Actions). To execute Smart Action for log a call, set the request object with the command to log a call. You can get the required command from the Smart Actions home page. Once the request object is ready it's published on the Smart Action context.

Here's a Typescript sample:

const tabContext: ITabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext();
const recordContext: IRecordContext =  tabContext.getActiveRecord(); 
let smartActionContext: IsmartActionContext = await recordContext.getSmartActionContext();
const requestObject: IExecuteSmartActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
requestObject.setId('SDA-LogACall-contacts');
smartActionContext.publish(requestObject).then((response: ISmartActionOperationResponse) => {
  console.log((response.getResponseData() as ISMartActionOperationResponseData).getId());
});
Here's a JavaScript sample:
const tabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext(); 
const recordContext =  await tabContext.getActiveRecord();  
let smartActionContext = await recordContext.getSmartActionContext();
const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
requestObject.setId('SDA-LogACall-contacts');
smartActionContext.publish(requestObject).then((response) => {
  console.log(response.getResponseData().getId());
});

Publish ExecuteSmartAction operation from TabContext for SDA-createContact-interactions Smart Action

Here are examples on how to use executeSmartAction from an Unknown contact page (ID is ActionId from Smart Actions).

Here's a Typescript sample:

const tabContext: ITabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext();
let smartActionContext: IsmartActionContext = await tabContext.getSmartActionContext();
const requestObject: IExecuteSmartActionRequest = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
requestObject.setId('SDA-createContact-interactions');
smartActionContext.publish(requestObject).then((response: ISmartActionOperationResponse) => {
  console.log((response.getResponseData() as ISMartActionOperationResponseData).getId());
});
Here's a JavaScript sample:
const tabContext =  await uiEventsFrameworkInstance.getCurrentBrowserTabContext()
let smartActionContext = await tabContext.getSmartActionContext();
const requestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
requestObject.setId('SDA-createContact-interactions');
smartActionContext.publish(requestObject).then((response) => {
  console.log(response.getResponseData().getId());
});

Publish ExecuteSmartAction operation after Pop Operation Success

Here are examples on how to use executeSmartAction from a contact page (ID is ActionId from Smart Actions).

Here's a Typescript sample:

const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const globalContext: IGlobalContext = await  uiEventsFrameworkInstance.getGlobalContext();
const requestObject: IPopFlowInAppRequest = uiEventsFrameworkInstance .requestHelper.createPublishRequest('PopOperation');
requestObject.setRecordType('Contact');
requestObject.setRecordId("CDRM_70980");
const popResponse: IPopFlowResponse = await globalContext.publish(requestObject);
const tabContext: ITabContext = await popResponse.getResponseData();
const recordContext: IRecordContext= await tabContext.getActiveRecord();
let smartActionContext: ISmartActionContext = await recordContext.getSmartActionContext();
const smartActionRequestObject: IExecuteSmartActionRequest  = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
smartActionRequestObject.setId('SDA-CreateServiceRequest-contacts');
let result: ISmartActionOperationResponse = await smartActionContext.publish(smartActionRequestObject);
Here's a JavaScript sample:
const uiEventsFrameworkInstance: IUiEventsFrameworkProvider = await CX_SVC_UI_EVENTS_FRAMEWORK.uiEventsFramework.initialize('MyFirstExtensionID');
const globalContext: IGlobalContext = await  uiEventsFrameworkInstance.getGlobalContext();
const requestObject:  = uiEventsFrameworkInstance.requestHelper.createPublishRequest('PopOperation');
requestObject.setRecordType('Contact');
requestObject.setRecordId("CDRM_70980");
const popResponse = await globalContext.publish(requestObject);
const tabContext = await popResponse.getResponseData();
const recordContext= await tabContext.getActiveRecord();
let smartActionContext = await recordContext.getSmartActionContext();
const smartActionRequestObject = uiEventsFrameworkInstance.requestHelper.createPublishRequest('ExecuteSmartAction');
smartActionRequestObject.setId('SDA-CreateServiceRequest-contacts');
let result = await smartActionContext.publish(smartActionRequestObject);