I have a custom Object, I was trying to override the NEW standard button with lightning component.

On Click of New button , below modal popup is opened and save the Data is working.

Issue: On Click of cancel button I'm just calling cancelDialog method in js. Expected is to close the modal. but It's doesn't do anything, It still remains in same Page.

Can anyone Please help me on this.

cancelDialog : function(component, helper) {      
    var home = $A.get("e.force:navigateToObjectHome");     


<aura:attribute name="items" type="NewData__c[]"/>
<aura:attribute name="enroll" type="NewData__c" default="{'sobjectType': 'NewData__c',
                                                            'NewData_Email__c':''}" />    

<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
    <div class="slds-modal__container">

        <header class="slds-modal__header">
            <lightning:buttonIcon iconName="utility:close"
            <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">New Enrollment</h2>

        <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
            <lightning:input   aura:id="field" messageWhenValueMissing ='Name cant be blank.'   required="true" value="{!v.enroll.NewData_Name__c}"
                             label="Name" />                
            <lightning:input type="email"   aura:id="field" messageWhenValueMissing ='Email cant be blank.'  required="true" value="{!v.enroll.NewData_Email__c}" label="Email" />
        <footer class="slds-modal__footer">
            <lightning:button variant="neutral" label="Cancel" onclick="{!c.cancelDialog}" />
            <lightning:button variant="brand" label="Save" onclick="{!c.createData}" />
<div class="slds-backdrop slds-backdrop_open"></div>

1 Answer 1


To navigate to an object home, set the object name on the scope attribute and fire the event.

Below will displays the home page for a custom object.

cancelDialog : function(component, helper) {      
        var home  = $A.get("e.force:navigateToObjectHome");
        home .setParams({
            "scope": "NewData__c"
        home .fire();

Please refer the below link:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .