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
Mohita KalraMohita 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}"/>

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);

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");
        var accountId = component.get("v.parentRecordId");
        console.log("account id"+accountId);

I am getting undefined in recordID in new component
David Zhu 🔥David Zhu 🔥
You may change your code a little bit:
        state": {
                 "recordId" : component.get("v.recordId")
var myRecordId= component.get("v.pageReference.state.recordId");