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
Santhiya Durai 2Santhiya Durai 2 

Navigate to newly created record in lightning component

Hi,
I need to create a Quote from Opportunity using Quick Action. Once new quote is created it should navigate to newly created quote record page. Record is getting created but navigation to Quote record is not happening. 
Component:
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId">      
<lightning:navigation aura:id="navigation"/>   
 <div class="slds-page-header" role="banner">        
<lightning:recordViewForm recordId="{!v.recordId}"  
                         objectApiName="Opportunity">       
 </lightning:recordViewForm>          
<lightning:messages/>      
<div class="slds-align_absolute-center" style="height:5rem">New Quote</div> 
    </div>    
 <lightning:recordEditForm aura:id="myform" objectApiName="SBQQ__Quote__c"  
                             onsubmit="{!c.handleSubmit}"     
                          onsuccess="{!c.handleSuccess}">        
 <lightning:messages/>         
<lightning:inputField fieldName="Invoice_To__c"/>         
<lightning:inputField fieldName="Ship_To_Location__c"/>        
 <lightning:inputField fieldName="Multi_Site_Quote__c"/>                 
<div class="slds-m-top_medium">             
<lightning:button label="Cancel" onclick="{!c.handleCancel}" />             
<lightning:button type="submit" label="Save" variant="brand"/>         
</div>     
</lightning:recordEditForm>      
</aura:component>

Controller:
({     handleCancel: function(cmp, event, helper)
 {         
$A.get("e.force:closeQuickAction").fire();     
},          
handleSubmit: function(cmp, event, helper)
 {         
event.preventDefault();         
var fields = event.getParam('fields');         
fields.SBQQ__Opportunity2__c = cmp.get("v.recordId");         
cmp.find('myform').submit(fields);     
},          
handleSuccess: function(cmp, event, helper)
 {         
var params = event.getParams();         
var quoteId = params.response.id;         
console.log(params.response.id);      
component.find("navigation")     
.navigate({         
"type" : "standard__recordPage",         
"attributes": {            
 "recordId"      : quoteId,            
 "actionName"    : actionName ? actionName : "view"   //clone, edit, view  
       } 
    }, true);   
  }  
})

Can anyone please correct me what I made wrong?
 
Thanks!

 
Regards
Santhiya
PriyaPriya (Salesforce Developers) 
Hey,

use the concept of page reference.

Refer this similar ask :-
https://developer.salesforce.com/forums/?id=9062I000000IFsbQAG

Thanks!
Puvvada VeerendraPuvvada Veerendra
Hi Santhiya,

The following Function will solve your Problem, PLease give a like once Done.
 
handleSuccess: function(component, event, helper) {
        var params = event.getParams();         
        var quoteId = params.response.id;
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
        "recordId": quoteId,
        "slideDevName": "detail"
        });
        navEvt.fire();
    }