Passing Parameters to a Lightning Component Quick Action?

Passing Parameters to a Lightning Component Quick Action?

On August 19, 2025, Posted by , In LWC Essentials,Salesforce Technical Questions, With Comments Off on Passing Parameters to a Lightning Component Quick Action?
Passing Parameters to a Lightning Component Quick Action

Question:

I have a Lightning component that is used as a quick action on multiple objects, such as Account and Contact. When the component is invoked, I can retrieve the recordId using:

<aura:attribute name="recordId" type="String" />

However, I also need to pass a custom parameter when invoking the quick action and retrieve it inside the component. Is there a way to send an additional parameter to the Lightning component quick action and access it within the component? If not, is there a workaround to achieve this?

Answer:

There is no direct way to pass additional parameters to a Lightning component quick action. However, a workaround is to encode the parameter in the quick action’s API name and extract it inside the component.

Enhance your career with CRS Info Solutions Salesforce training, providing expert mentorship, hands-on experience, and in-depth knowledge—sign up for a free demo today!!!

For example, when creating the quick action, name it using a convention like:

API Name: ParamValue_XXX_ActionName

For instance, if the quick action is created on the Account object and you want to pass Foo as a parameter, name it:

Foo_XXX_MyQuickAction

Then, in the Lightning Web Component, use CurrentPageReference to extract the parameter from the API name:

import { api, wire } from "lwc";
import { CurrentPageReference } from "lightning/navigation";

export default class MyComponent extends LightningElement {
    paramValue;

    @wire(CurrentPageReference)
    parseParam(currentPageReference) {
        if (currentPageReference.type === "standard__quickAction") {
            let quickActionPath = currentPageReference.attributes.apiName; // e.g., Account.Foo_XXX_MyQuickAction
            this.paramValue = quickActionPath.split(".")[1].split("_XXX_")[0]; // Extracts "Foo"
        }
    }
}

Explanation: This Lightning Web Component extracts a parameter encoded in the quick action’s API name. It uses @wire(CurrentPageReference) to access the current page reference and checks if it’s a standard__quickAction. The component then parses the apiName, splits it using a predefined _XXX_ separator, and stores the extracted value in paramValue.

This method allows you to pass one additional parameter through the quick action name. Although it’s not an official approach, it provides a practical workaround.

Transform Your Career with Salesforce Training in Bangalore

Unlock the doors to a successful career with our industry-driven salesforce course. Tailored to help you become an expert in the Salesforce ecosystem, our program offers in-depth training across Admin, Developer, and AI tracks, along with expert guidance for certification and thorough interview preparation.

Our hands-on learning approach equips you with practical skills, ensuring you’re ready to tackle real-world challenges and stand out in the job market. Salesforce training in Bangalore With comprehensive class materials, personalized mentorship, and a focus on practical learning, we provide everything you need to excel.

Take the first step towards transforming your career—join our free demo class today and discover how our expert-led training can make a difference!!!

Comments are closed.