Create Quick Action
Roles:
Salesforce AdministratorSalesforce Developer
Creating a quick action can be done either via a Flow invocable or through Apex. Quick actions are actions that don’t belong to a specific sequence.
If the custom setting GS_PublicSettings__c.logging_throwExceptions__c = true, an exception is thrown when there is an error. If the setting is false, the error message is returned in the result.
Flow Invocable Action
Within the flow editor, add a new element of type Action. In Search Actions, search for: Create Quick Action.
Parameters
- Label: Your Label
- API Name: Your API Name
- Action Name: Your Action Name
- Action Type: Call, SMS or Task
- Expected Execution Date: Any datetime, defaults to current datetime
- Participant Id: Lead or Contact Id
- Participant Ids: List of Lead or Contact Id
- Configuration: Can leave blank, or provide a JSON string in the format:
{"task": {"Subject": "Test Subject 3"}} - Owner Id: Can leave blank for current owner, or populate with a User Id
Apex Implementation
Example 1: Create a Call Action with Minimal Configuration
// Create a list of Quick Action requests
List<RDNACadence.QuickActionCreator.QuickActionRequest> requests =
new List<RDNACadence.QuickActionCreator.QuickActionRequest>();
// Example 1: Create a Call action with minimal configuration
RDNACadence.QuickActionCreator.QuickActionRequest callRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
callRequest.actionName = 'Sales call';
callRequest.actionType = 'Call'; // Or SMS
callRequest.participantId = '003xxx'; // Replace with actual Contact/Lead ID
// expectedExecutionDate and ownerId will default if not provided
requests.add(callRequest);
// Call the service
List<RDNACadence.QuickActionCreator.QuickActionResult> results =
RDNACadence.QuickActionCreator.createQuickActions(requests);
// Process results
for (RDNACadence.QuickActionCreator.QuickActionResult result : results) {
if (result.success) {
System.debug('Successfully created Quick Action with ID: ' + result.participantActionId +
' for Participant: ' + result.participantId);
} else {
System.debug('Failed to create Quick Action for Participant: ' + result.participantId +
' Error: ' + result.errorMessage);
}
}Example 2: Create a Task with Complex Configuration
// Example 2: Create a Task with complex configuration
RDNACadence.QuickActionCreator.QuickActionRequest complexTaskRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
complexTaskRequest.actionName = 'Product demo preparation';
complexTaskRequest.actionType = 'Task';
complexTaskRequest.participantId = '003xxx'; // Replace with actual Contact/Lead ID
complexTaskRequest.expectedExecutionDate = Datetime.now().addHours(2);
complexTaskRequest.configuration = '{"task": {"Description": "Prepare demo materials and agenda", "Priority": "Normal", "Status": "Not Started", "Subject": "Demo prep"}}';
requests.add(complexTaskRequest);
// Call the service
List<RDNACadence.QuickActionCreator.QuickActionResult> results =
RDNACadence.QuickActionCreator.createQuickActions(requests);
// Process results
for (RDNACadence.QuickActionCreator.QuickActionResult result : results) {
if (result.success) {
System.debug('Successfully created Quick Action with ID: ' + result.participantActionId);
} else {
System.debug('Failed to create Quick Action: ' + result.errorMessage);
}
}Example 3: Create an Email Action
// Example 3: Create an Email action
RDNACadence.QuickActionCreator.QuickActionRequest emailRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
emailRequest.actionName = 'Followup Email';
emailRequest.actionType = 'Email';
emailRequest.participantIds = new List<Id>{'003xx1', '003xx2'}; // Replace with actual Contact/Lead IDs
emailRequest.templateId = 'a0Hxxx'; // Replace with Template Id
// expectedExecutionDate and ownerId will default if not provided
requests.add(emailRequest);
// Call the service
List<RDNACadence.QuickActionCreator.QuickActionResult> results =
RDNACadence.QuickActionCreator.createQuickActions(requests);
// Process results
for (RDNACadence.QuickActionCreator.QuickActionResult result : results) {
if (result.success) {
System.debug('Successfully created Quick Action with ID: ' + result.participantActionId);
} else {
System.debug('Failed to create Quick Action: ' + result.errorMessage);
}
}Complete Example with Error Handling
// Create a list of Quick Action requests
List<RDNACadence.QuickActionCreator.QuickActionRequest> requests =
new List<RDNACadence.QuickActionCreator.QuickActionRequest>();
// Example 1: Create a Call action with minimal configuration
RDNACadence.QuickActionCreator.QuickActionRequest callRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
callRequest.actionName = 'Sales call';
callRequest.actionType = 'Call';
callRequest.participantId = '003xxx'; // Replace with actual Contact/Lead ID
requests.add(callRequest);
// Example 2: Create a Task with complex configuration
RDNACadence.QuickActionCreator.QuickActionRequest complexTaskRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
complexTaskRequest.actionName = 'Product demo preparation';
complexTaskRequest.actionType = 'Task';
complexTaskRequest.participantId = '003xxx'; // Replace with actual Contact/Lead ID
complexTaskRequest.expectedExecutionDate = Datetime.now().addHours(2);
complexTaskRequest.configuration = '{"task": {"Description": "Prepare demo materials and agenda", "Priority": "Normal", "Status": "Not Started", "Subject": "Demo prep"}}';
requests.add(complexTaskRequest);
// Example 3: Create an Email action
RDNACadence.QuickActionCreator.QuickActionRequest emailRequest =
new RDNACadence.QuickActionCreator.QuickActionRequest();
emailRequest.actionName = 'Followup Email';
emailRequest.actionType = 'Email';
emailRequest.participantIds = new List<Id>{'003xx1', '003xx2'}; // Replace with actual Contact/Lead IDs
emailRequest.templateId = 'a0Hxxx'; // Replace with Template Id
requests.add(emailRequest);
try {
// Call the QuickActionCreator
List<RDNACadence.QuickActionCreator.QuickActionResult> results =
RDNACadence.QuickActionCreator.createQuickActions(requests);
// Process the results
for (RDNACadence.QuickActionCreator.QuickActionResult result : results) {
if (result.success) {
System.debug('Successfully created Quick Action with ID: ' + result.participantActionId +
' for Participant: ' + result.participantId);
} else {
System.debug('Failed to create Quick Action for Participant: ' + result.participantId +
' Error: ' + result.errorMessage);
}
}
} catch (Exception e) {
System.debug('Exception occurred: ' + e.getMessage());
}Configuration JSON Format
For Task actions, the configuration JSON can include task fields such as Subject, Description, Priority, and Status:
{
"task": {
"Subject": "Task Subject",
"Description": "Task Description",
"Priority": "Normal",
"Status": "Not Started"
}
}Result Object
The QuickActionResult object contains:
- success: Boolean indicating if the action was created successfully
- participantActionId: The ID of the created participant action
- participantId: The ID of the participant (Lead or Contact)
- errorMessage: Error message if the creation failed
- successfulIds: List of successfully created participant action IDs
- errors: List of error messages
Last updated on