Newer Version Available

This content describes an older version of this product. View Latest

QuickActionDefaultsHandler Interface

The QuickAction.QuickActionDefaultsHandler interface lets you specify the default values for the standard Email and Send Email actions in the case feed. You can use this interface to specify the From address, CC address, BCC address, subject, and email body for the Email action in the case feed. You can use the interface to pre-populate these fields based on the context where the action is displayed, such as the case origin (for example, country) and subject.

Namespace

QuickAction

Usage

To specify default values for the standard Email action in the case feed, create a class that implements QuickAction.QuickActionDefaultsHandler.

The QuickAction.QuickActionDefaultsHandler interface works in Salesforce Classic and Lightning Experience.

When working in Lightning Experience, keep the following things in mind:
  • The interface overrides email values set up with predefined IDs.
  • The interface works with the out-of-the-box Email action provided on cases. You can also use the interface with custom Email actions for the case object.
  • The interface in Lightning Experience doesn’t support:
    • Email attachments
    • Custom email fields
    • Visualforce email templates, which are a type of email template available in Salesforce Classic
  • The From Address picklist isn’t customizable in Send Email action types via the QuickActionDefaultsHandler Interface.
  • If your Apex interface adds content to the email body, merge fields display as unresolved. During preview and send, the merge fields resolve.

When you implement this interface, provide an empty parameterless constructor.

QuickActionDefaultsHandler Methods

The following are methods for QuickActionDefaultsHandler.

onInitDefaults(actionDefaults)

Implement this method to provide default values for the standard Email action in the case feed.

Signature

public void onInitDefaults(QuickAction.QuickActionDefaults[] actionDefaults)

Parameters

actionDefaults
Type: QuickAction.QuickActionDefaults[]
This array contains only one item of type QuickAction.SendEmailQuickActionDefaults.

Return Value

Type: void

QuickActionDefaultsHandler Example Implementations

These examples are implementations of the QuickAction.QuickActionDefaultsHandler interface.

In this example, the onInitDefaults method checks whether the element passed in the array is for the standard Email action in the case feed. Then, it performs a query to retrieve the case that corresponds to the context ID. Next, it sets the value of the BCC address of the corresponding email message to a default value. The default value is based on the case reason. Finally, it sets the default values of the email template properties. The onInitDefaults method determines the default values based on two criteria: first, whether a reply action on an email message initiated the call to the method, and second, whether any previous emails attached to the case are associated with the call.

In this example, the onInitDefaults method checks whether the element passed in the array is for the standard Email action in the case feed. Then it performs a query to determine if the case Priority is set to High. If the Priority is set to High, the email address managers@acme.com is appended to the BCC field.

In this example, the onInitDefaults method checks whether the element passed in the array is for the standard Email action in the case feed. Then it performs a query to determine if the case Type is set to Problem. If the type is set to Problem, the First Response email template is inserted into the body of the email.

In this example, the onInitDefaults method checks whether the element passed in the array is for the standard Email action in the case feed. Then it performs a query to determine if the email is a Reply or Reply All email. If email is a Reply or Reply All email, the corresponding email templates for these emails are inserted into the body of the email.