How to pass parameters for Lightning component called via quick a action

I have a lightning component which is included inside a visualForce page.
When accessing the page directly with a url parameter ‘Id’ this works fine
(component loads inside the vf page and display record details)

My next step is to call this vf page from a quick action, so I created a quick action and referred the vf page.

PROBLEM; when call from the quick action it doesn’t set value to the “Id” parameter

Can someone tell me what’s wrong here, and provide an explanation?

VF page

<apex:page standardController="Account">
    <apex:includeScript value="/lightning/lightning.out.js" />
    <apex:stylesheet value="/resource/slds0120/assets/styles/salesforce-lightning-design-system-vf.css"/>
    <apex:includeLightning />
    <div class="slds" style="margin-top:10px;margin-left:10px;"> 
        <div id="lightning" />

        var accountId = "{!$}";
        $Lightning.use("c:AccountListWrapper1", function() {
                { "Id" : accountId },
                  function(cmp) {
                    // do some stuff

HELPER.JS (this.getURLParameter(‘id’); returns null when called via quick action 🙁 )

     doInit : function(cmp, event, helper) {
         var accountId = this.getURLParameter('id');
         var action = cmp.get("c.getAccount");
         var params = {"id":accountId};

        var self = this;
        action.setCallback(this, function(response) {
            try {
                self.actionResponseHandler(response, cmp, self, self.gotAccount);
            catch (e) {
                alert('Exception ' + e);
    gotAccount : function(cmp, helper, acc) {

        cmp.set('v.account', acc);
    getURLParameter : function(param) {
        var result=decodeURIComponent((new RegExp('[?|&]' + param + '=' + '([^&;]+?)(&|#|;|$)').exec(||[,""])[1].replace(/+/g, '%20'))||null
        return result;
    actionResponseHandler : function (response, component, helper, cb, cbData) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var retVal=response.getReturnValue();
                cb(component, helper, retVal, cbData);
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + errors[0].message);
                else {
                    alert("Unknown error");
        catch (e) {
            alert('Exception in actionResponseHandler: ' + e);


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I resolved the issue with adding an attribute to the component and, set the account Id to the new attribute as follows and referred it back in the doInitit() helper method.

New Attribute in component

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

Changes to the script inside the .VFP (setting the value to the accountId component attribute )

var accountId = "{!$}";

$Lightning.use("c:AccountListWrapper1", function() {
          { "accountId" : accountId },
             function(cmp) {
                // do some stuff

Accessed via doInit() method as follows

var accountId = cmp.get("v.accountId");

Method 2

You need to set force:hasRecordId in implements (note: you can set multiple “forces” by using “comma”)

implements="force:lightningQuickActionWithoutHeader, force:hasRecordId"

The second thing, call get method on component as in this example:

var contractId = component.get("v.recordId");

Now you have the current record ID in contractId variable.

Method 3

I am getting value till the helper, But I am not able pass this value to the component..

var accountId = cmp.get("v.accountId");


the below link have full details..
How to get current page id in Lightning controller?

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x