When i click on Save button i do not want the page to be redirected to to object detail page.I want to be on same page where me performing the action.How this can be achieved in lightning .I tried to use event.preventDefault().But it is not working.


1 Answer 1


Using $A.get('e.force:createRecord') is not possible to customise save/submit.

But I can suggest an alternative approach.

Step 1 : First create a lighting component lets say Comp1 using lightning:recordForm. Here, you can customise onsubmit handler the way you want.

Step 2 : Use lightning:overlayLibrary to dynamically open Comp1 as a modal.

Step 3 : replace $A.get('e.force:createRecord').fire() with below code.

  $A.createComponent("Comp1", {},
       function(content, status) {
           if (status === "SUCCESS") {
               modalBody = content;
                   header: "Create Record",
                   body: modalBody, 
                   showCloseButton: true,
                   cssClass: "mymodal",
                   closeCallback: function() {
                       //alert('You closed the alert!');

If you would like my suggestion you can mark it as an answer.

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