You need to sign in to do that
Don't have an account?
mahamed raheem
I have to navigate LWC to Aura component, so in this scenario how to pass recordId LWC to aura component can any one help me on this.
Hi,
I have to navigate LWC to Aura component, so in this scenario how to pass recordId LWC to aura component
can any one help me on this.
I have to navigate LWC to Aura component, so in this scenario how to pass recordId LWC to aura component
can any one help me on this.
Please try this code:
LWC js file:
navigateToComponent() {
this[NavigationMixin.Navigate]({
"type": "standard__component",
"attributes": {
"componentName": "c__navigateAura",
},
state: {
c__recordId: this.recordId
}
});
}
Aura Component:
navigateAura.cmp
<aura:component implements="lightning:isUrlAddressable,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="test" type="string"/>
{!v.recordId} --->this record Id comping Null.
</aura:component>
navigateAura.js:
({
doInit : function(component, event, helper) {
var myPageRef = component.get("v.pageReference");
var recordId = myPageRef.state.c__recordId;
component.set("v.recordId", recordId);
}
})
I hope it helps you.
Please let me know if you have any other query and If this solution is helpful then please mark it as Best Answer.
Thanks,
Ankit Rathor
All Answers
Greetings to you!
You need to use lightning/navigation in LWC. If you are navigating to Lightning Component from LWC, you need to implement the lightning:isUrlAddressable interface in your Lightning Component.
Please refer to the below links which might help you further with the above requirement.
https://www.salesforcecodecrack.com/2019/06/navigation-service-in-lightning-web.html
https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.use_navigate
https://developer.salesforce.com/docs/component-library/bundle/lightning-navigation/documentation
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I used lightning:isUrlAddressable interface in my lighting aura component
But am unable get the record Id from LWC
please find below LWC code
NavigateToViewAll(){
this[NavigationMixin.Navigate]({
"type": "standard__component",
"attributes": {
"componentName": "c__li_ObjectHistory_ViewAll",-->this my aura component
"recordId": this.recordId
}
});
Aura Component:
<aura:component implements="lightning:isUrlAddressable,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="id"/>
<aura:attribute name="test" type="string"/>
{!v.recordId} --->this record Id comping Null.
</aura:component>
Please help me.
Please try this code:
LWC js file:
navigateToComponent() {
this[NavigationMixin.Navigate]({
"type": "standard__component",
"attributes": {
"componentName": "c__navigateAura",
},
state: {
c__recordId: this.recordId
}
});
}
Aura Component:
navigateAura.cmp
<aura:component implements="lightning:isUrlAddressable,force:hasRecordId" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="recordId" type="String"/>
<aura:attribute name="test" type="string"/>
{!v.recordId} --->this record Id comping Null.
</aura:component>
navigateAura.js:
({
doInit : function(component, event, helper) {
var myPageRef = component.get("v.pageReference");
var recordId = myPageRef.state.c__recordId;
component.set("v.recordId", recordId);
}
})
I hope it helps you.
Please let me know if you have any other query and If this solution is helpful then please mark it as Best Answer.
Thanks,
Ankit Rathor