You need to sign in to do that
Don't have an account?
Mohita Kalra
Hi All , My navigate to component URL is opening but I am not able to state record Id from it
This is my code:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="pageReference" type="Object"/>
<aura:handler name="init" value="this" action="{!c.doInit}"/>
<aura:attribute name="url" type="String"/>
<aura:attribute name="accId" type="Id"/>
<lightning:navigation aura:id="navService"/>
<div style="background:#ffffff; margin:2px; border-radius: 2px; padding-left: 12px; padding-right: 12px; padding-top: 2px; padding-bottom: 7px;">
<p style="font-size:90%;">
<lightning:button variant="brand" label="New Case" title="New Case" onclick="{!c.mycomp}"/>
</p>
</div>
</aura:component>
Component :
mycomp : function(component, event, helper){
var navService = component.find("navService");
var pageReference = {
"type": "standard__component",
"attributes": {
"componentName": "c__NewCase"
},
"state": {
recordId : component.get("v.recordId")
}
};
component.set("v.pageReference", pageReference);
navService.navigate(pageReference);
This code is opening my component but i am getting undefined for recordId attribute.
doInit function in Controller of New Case component is :
var myPageRef = component.get("v.pageReference");
component.set("v.parentRecordId",myPageRef.state.recordId);
var accountId = component.get("v.parentRecordId");
console.log("account id"+accountId);
I am getting undefined in recordID in new component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:attribute name="pageReference" type="Object"/>
<aura:handler name="init" value="this" action="{!c.doInit}"/>
<aura:attribute name="url" type="String"/>
<aura:attribute name="accId" type="Id"/>
<lightning:navigation aura:id="navService"/>
<div style="background:#ffffff; margin:2px; border-radius: 2px; padding-left: 12px; padding-right: 12px; padding-top: 2px; padding-bottom: 7px;">
<p style="font-size:90%;">
<lightning:button variant="brand" label="New Case" title="New Case" onclick="{!c.mycomp}"/>
</p>
</div>
</aura:component>
Component :
mycomp : function(component, event, helper){
var navService = component.find("navService");
var pageReference = {
"type": "standard__component",
"attributes": {
"componentName": "c__NewCase"
},
"state": {
recordId : component.get("v.recordId")
}
};
component.set("v.pageReference", pageReference);
navService.navigate(pageReference);
This code is opening my component but i am getting undefined for recordId attribute.
doInit function in Controller of New Case component is :
var myPageRef = component.get("v.pageReference");
component.set("v.parentRecordId",myPageRef.state.recordId);
var accountId = component.get("v.parentRecordId");
console.log("account id"+accountId);
I am getting undefined in recordID in new component
David Zhu 🔥
You may change your code a little bit: