function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sancasanca 

how to get the recordid in the component which is invoked through quick action present in record page

Hi Devs ,
I have a component which is invoked through quick action present in event record page .The component is referring to force:hasRecordId interface .
The value of recordid is resulting to  undefined  when debugged. 
<!--component>

<aura:component controller="customLookUpController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

<!--controller>
({
    doInit: function(component,event,helper) {
        var getId = component.get("v.recordId");   -- > undefined 
},
})
Best Answer chosen by sanca
Shruti SShruti S
Okay, then could you please try this : 
<!--parent component invoked from quick action-->
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction">
    <c:childComponent entityId="{!v.recordId}" />
</aura:component>

<!--child component-->
<aura:component controller="customLookUpController">
    <aura:attribute name="entityId" type="String" access="public" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>

<!--controller-->
({
    doInit: function(component,event,helper) {
        var getId = component.get( "v.entityId" );
    }
})

All Answers

Shruti SShruti S
This is weird. It should have worked. Can you try adding this script - 
var recordId = component.get( "v.recordId" );
console.log( recordId );
alert( recordId );
And if that doesn't work, I would add an attribute and then check too like this = 
<aura:attribute name="recordId" type="String" access="public" />
Yes, I agree that if you are inheriting the force:hasRecordId, you don't have to explicitly add this attribute but just for the heck of it.
sancasanca
Hi Shruti ,

Tried explicity declaring recordId  , no luck ..
Just FYI , The component where i am trying to fetch the id is the child of component invoked from the quik action .
Apologize for not mentioning this earlier . Will this scenario cause the issue ?
Appreciate if any leads on this ..
<!--parent component invoked from quick action>
<aura:component >
<c:child component>
</aura:component>

<!--child component>

<aura:component controller="customLookUpController" implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

<!--controller>
({
    doInit: function(component,event,helper) {
        var getId = component.get("v.recordId");   -- > undefined 
},
})

 
Shruti SShruti S
Okay, then could you please try this : 
<!--parent component invoked from quick action-->
<aura:component implements="flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction">
    <c:childComponent entityId="{!v.recordId}" />
</aura:component>

<!--child component-->
<aura:component controller="customLookUpController">
    <aura:attribute name="entityId" type="String" access="public" />

    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>

<!--controller-->
({
    doInit: function(component,event,helper) {
        var getId = component.get( "v.entityId" );
    }
})
This was selected as the best answer
sancasanca
Hi Shruti ,

Thanks for the inputs ,It worked like a charm .. :)

Nanni 
GovindarajGovindaraj
Hi Sanju,

Could you please post the worked solution in this thread. We're also facing similar kind of issue.

Thanks,
Govindaraj.S
Vadzim RyndinVadzim Ryndin
Hi, this works for me to get recordId for a component  in the Utility Bar:

<aura:component description="Aura Container in Utility Bar for LWC cmp" 
                             implements="force:hasRecordId, force:lightningQuickAction, lightning:utilityItem"  access="global">
    <c:childLwcCmp recordId="{!v.recordId}"  />  
</aura:component>

<!--child LWC Cmp-->
export default class childLwcCmp extends LightningElement {
   
    _recordId;
   
    @api
    get recordId() {
        return this._recordId;
    }
    set recordId(value) {
        this.setAttribute('recordId', value);
        this._recordId = value;

//for the first time NULL comes, but then immediately the current recordID comes from the aura
        if (this.recordId == null) {   
            console.log('-/-NULL-/-', this.recordId);
        } else {
            this.doInit();
        }
    }