0

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.

3
  • 1
    I believe aura uses camel case so you'd want to provide the value to lwc as recordId="{v.recordId}"? Commented May 9 at 23:04
  • ahhhh, (╯°□°)╯︵ ┻━┻, went so far down the rabbit hole on this one. that did the trick @KrisGoncalves Commented May 9 at 23:20
  • @KrisGoncalves if you'd like the points I can accept that as an answer. happy to answer it myself if you're good Commented May 9 at 23:31

1 Answer 1

1

I haven't yet seen any strict documentation/reference of it other than the note here about camel case in aura.

In an Aura component, to refer to either Aura components or Lightning web components, use camel case with a colon separating the namespace and the component name

But it does link to lwc recipe repo which does have examples of aura referencing lwc and you can see the API properties are camel case.

So you'd just need to update your reference to the lwc API variable to be recordId

<c:memoEditor recordId="{!v.recordId}" 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.