Quick Action APIs in Lightning Experience
A lightning:quickActionAPI component allows you to access methods for programmatically controlling quick actions on record pages. This component is supported in Lightning Experience and supports utility pop-out. This component requires API version 43.0 and later.
| Required Editions |
|---|
| Available in: Lightning Experience |
| Available in: Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions |
For example, if you have a custom Aura component that displays Knowledge articles, you can use the lightning:quickActionAPI component to attach and send a Knowledge article from your custom component using the Email quick action on the case record page.
To access these methods, create an instance of the lightning:quickActionAPI component inside your Aura component or page and assign an aura:id attribute to it.
1<lightning:quickActionAPI aura:id="quickActionAPI"/>This component provides similar functionality to the Publisher APIs in Salesforce Classic.
Sample Code
This example creates two buttons that interact with the Update Case quick action on a case record page in Lightning Experience. The controller code uses the following Quick Action API methods: selectAction, setActionFieldValues, and invokeAction.
Component code:
1<aura:component implements="flexipage:availableForRecordHome" description="My Lightning Component">
2 <lightning:quickActionAPI aura:id="quickActionAPI" />
3 <div>
4 <lightning:button label="Select Update Case Action" onclick="{!c.selectUpdateCaseAction}" />
5 <lightning:button label="Update Case Status Field" onclick="{!c.updateCaseStatusAction}" />
6 </div>
7</aura:component>Controller code:
1({
2 selectUpdateCaseAction: function (cmp, event, helper) {
3 var actionAPI = cmp.find("quickActionAPI");
4 var args = { actionName: "Case.UpdateCase" };
5 actionAPI
6 .selectAction(args)
7 .then(function (result) {
8 // Action selected; show data and set field values
9 })
10 .catch(function (e) {
11 if (e.errors) {
12 // If the specified action isn't found on the page,
13 // show an error message in the my component
14 }
15 });
16 },
17
18 updateCaseStatusAction: function (cmp, event, helper) {
19 var actionAPI = cmp.find("quickActionAPI");
20 var fields = {
21 Status: { value: "Closed" },
22 Subject: { value: "Sets by lightning:quickActionAPI component" },
23 accountName: { Id: "accountId" },
24 };
25 var args = { actionName: "Case.UpdateCase", entityName: "Case", targetFields: fields };
26 actionAPI
27 .setActionFieldValues(args)
28 .then(function () {
29 actionAPI.invokeAction(args);
30 })
31 .catch(function (e) {
32 console.error(e.errors);
33 });
34 },
35});-
Quick Action API Considerations
Before working with the Lightning Quick Action JavaScript API methods, review some considerations that might impact your implementation.
-
Allows custom components to get a list of the available actions on a record page.
-
Allows custom components to get a list of the available fields for a specific action on a record page.
-
Allows custom components to access a custom quick action and pass data or messages to it.
-
Allows custom components to access selected quick actions on a record page.
-
Allows custom components to save or submit the quick action on a record page.
-
Refreshes the current record page.
-
Allows custom components to select and focus on a quick action on a record page.
-
Allows custom components to select a quick action on a record page and then specify field values for that action.
See Also