Quick Action API

lightning:quickActionAPI

Work with quick actions on record pages.

For Aura components only. For LWC quick actions, see the Lightning Web Components Developer Guide.

For Use In

Lightning Experience

A lightning:quickActionAPI component allows you to access methods for programmatically controlling quick actions on record pages.

For example, if you have a custom component that displays Knowledge articles, you can use the lightning:quickActionAPI component to attach and send a Knowledge article from your custom component via the Email quick action on the case record page.

To access the methods, create an instance of the lightning:quickActionAPI component inside your Lightning component or page and assign an aura:id attribute to it.

This example creates two buttons that interact with the Update Case quick action on a case record page in Lightning Experience.

The buttons call the following client-side controller.

The lightning:quickActionAPI component provides similar functionality to the Salesforce Classic Publisher JavaScript API. This component also supports utility pop-out.

To successfully use the Lightning Quick Action JavaScript APIs, make sure that you add the lightning:quickActionAPI component to a tab or location on the page that's visible when the page loads. If the component isn't visible when the page loads, the API isn't used until the component is visible. For example, if you add the component to an Accordion component section that isn't the default expanded one, the API is called only when a user opens that accordion section.

This component supports the following methods. Most methods take only one argument, a JSON array of parameters. For more information on these methods, see the Publisher and Quick Action Developer Guide.

getAvailableActions()

A method that allows custom components to get a list of the available actions on a record page.

Returns a Promise. Success resolves to a response object. The Promise is rejected on error response. Common response object:

getAvailableActionFields({actionName})

A method that allows custom components to get a list of the available fields for a specific action on a record page.

Returns a Promise. Success resolves to a response object. The Promise is rejected on error response. Common response object:

getCustomAction({actionName})

A method that allows custom components to get a custom quick action and pass data or messages to it.

  • actionName (string): The name of the quick action that you want to access.

Returns a Promise. Success resolves to a response object. The Promise is rejected on error response. Common response object:

Example:

getSelectedActions()

A method that allows custom components to get selected quick actions on a record page.

Returns a Promise. Success resolves to a response object. The Promise is rejected on error response. Common response object:

invokeAction({actionName})

A method that allows custom components to save or submit the quick action on a record page.

  • actionName (string): The name of the quick action that you want to submit.

Returns a Promise. Success resolves to true. The Promise is rejected on error response.

refresh()

Refreshes the current record page.

selectAction({actionName})

A method that allows custom components to select and focus on a quick action on a record page.

  • actionName (string): The name of the quick action that you want to select and set focus to.

Returns a Promise. Success resolves to true. The Promise is rejected on error response. Common response object:

setActionFieldValues({actionName, targetFields, parentFields, submitOnSuccess})

A method that allows custom components to select a quick action on a record page and then specify field values for that action. Because this method also selects the quick action, you don't need to use the selectAction method. To submit the quick action updates, pass submitOnSuccess as true.

  • actionName (string): The name of the quick action that you want to select and set focus to.
  • parentFields (object): Optional. The fields that you want to update on the current record. For example, if you want to set field values on the Email quick action on the case record page, the case object is the parent record. You can use the parentFields parameter to change the value of the case record:
  • targetFields (object): The fields that you want to update on the quick action. Use format:
  • submitOnSuccess (boolean): Optional. Set to true if you want to save and submit the quick action after setting the field values. Default is false.

Returns a Promise. Success resolves to true. The Promise is rejected on error response. Common response object: