Question
If I've got an LWC component, memoEditor, that's driven by a recordId attribute. It works great on lightning record pages. Now I'd like to be able to use my memoEditor in an Aura component so I can use it in a quick action that will show up the chatter publisher. But for the life of me I can't figure out how to get the recordId attribute down from aura to my memoEditor component.
Code Details
Aura Stuff
Nothing crazy in here, just passing a value down.
<aura:component implements="force:lightningQuickAction,force:hasRecordId"> <aura:attribute name="recordId" type="String" /> My Record Id: "{!v.recordId}" <c:memoEditor record-id="{!v.recordId}" /> </aura:component> When I open up chatter publisher, everything looks good. I can see the My Record Id dumped in the html, so I know aura has a value for v.recordId. All my html for my c:memoEditor loads correctly, but it's save method only sees null for it's record Id.
LWC
My LWC memoEditor is pretty basic it makes an update to a case object using it's recordId attribute.
@api recordId; async mySaveLogic() { // expects this.recordId to be populated } It's always null in this case. I've done a couple things to try and work around it
Wire to CurrentPageReference
This has worked for me in some other quick action cases where the recordId is delayed in getting set. At least for this use case, the method never gets called.
// copious console.logs removed for clarify @wire(CurrentPageReference) getStateParameters(currentPageReference) { if (this.wireRecordId === undefined && currentPageReference?.state?.recordId !== undefined) { this.wireRecordId = currentPageReference.state.recordId; } } Console logging
I've also checked things in connectedCallback and other lifecycle events to see if maybe it's getting set and then cleared.
Why do I care?
I want to add a custom action to the case chatter feed with this component. The only way I've found to do that is to create an Aura component as a quick action. Quick actions with LWC component targets won't show up.
recordId="{v.recordId}"?