I am using $A.get('e.force:createRecord') on click of my lightning component's button. I saw the default behaviour is after save it redirects to that object's detail page.

Is there is any way out to override this behaviour?


you can use "panelOnDestroyCallback" function to redirect to a custom Url.

Please refer to the sample code:

 var eve = $A.get("e.force:createRecord");

        "entityApiName": "Contact",
         "panelOnDestroyCallback": function(event) {
             window.location.href = "https://www.google.com";


Not to my knowledge, asuming that you are having users fill in some kind of form, you should be better of using


and use its available events, such as:

onsuccess Action The action triggered when the form is saved.

some of the advantages of this component are that it handles FLS, CRUD and is quite easy to use:

<lightning:recordEditForm objectApiName="sObjectName">
    <div class="slds-grid">
        <div class="slds-col slds-size_1-of-2">
            <!-- Your lightning:inputField components here -->
        <div class="slds-col slds-size_1-of-2">
            <!-- More lightning:inputField components here -->

and add your custom logic to do whatever it is you need done.

Otherwise, you can always Call a Server-Side Action


"saveSomething" : function(cmp) {

    var action = cmp.get("c.saveSobject");
    action.setParams({ field: cmp.get("v.fieldName") });

    action.setCallback(this, function(response) {
        var state = response.getState();
        if (state === "SUCCESS") {
            // custom action here 
        else if (state === "INCOMPLETE") {
            // do something
        else if (state === "ERROR") {
            var errors = response.getError();
            if (errors) {
                if (errors[0] && errors[0].message) {
                    console.log("Error message: " + 
            } else {
                console.log("Unknown error");

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.