I have a lightning component and in my component i have on button for new record its work fine but after record created it goes to record detail page. I want to prevent navigate event and close the model and show the toas message on the same page. here is my sample code .

<ui:button label="New" class="newbtn right" press="{!c.newEvent}"/> 


 newEvent : function(component, event,helper) {

        var createRecordEvent = $A.get("e.force:createRecord");
            "entityApiName":  "Event"


2 Answers 2


This code work for me..

function (component, event, helper) {
        var windowHash = window.location.hash;
        var recordEvent = $A.get("e.force:createRecord");
            "entityApiName": "Event",
            "panelOnDestroyCallback": function(event) {
                window.location.hash = windowHash;
  • Welcome to SFSE! Please take the tour and read How to Answer. Right now, this answer is what we call a code dump. It's a block of code with no explanation as to how it works. Code dumps tend to make poor answers, and lead to a lot of back-and-forth in the comments like "that didn't work" and "try this instead" that make it hard for others to apply this to their own problems. The best answers tend to explain things like what the problem is, how to fix it, and why the fix works. You should edit your answer to include more detail.
    – Derek F
    Mar 20, 2020 at 11:26

You have to create your own custom component. There is no way to stop the navigation for the standard event provided by Salesforce.

  • why the downvotes? This is the only possible answer and it's correct in my view. Nov 10, 2017 at 13:24
  • @praveen just fyi the above mention solution work perfectly
    – Faisal
    Mar 30, 2020 at 19:03

You must log in to answer this question.

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