6

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

JS-controller

 newEvent : function(component, event,helper) {

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



    }

2 Answers 2

-1

This code work for me..

function (component, event, helper) {
        var windowHash = window.location.hash;
        var recordEvent = $A.get("e.force:createRecord");
        recordEvent.setParams({
            "entityApiName": "Event",
            "panelOnDestroyCallback": function(event) {
                window.location.hash = windowHash;
            },
            "navigationLocation":"LOOKUP"
        });
        recordEvent.fire();
    }
1
  • 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
1

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

2
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.