I am working with Lightning Experience. I have used force:createRecord for creating new record, and everything work fine unless the redirection after Save button clicked. (it's redirected to the record page while I hope I could make it stay and only refresh current page).

Could you guy please tell me how to refresh current page after click Save button?

P/s: Save button is a button of a page (look like dialog) when force:createRecord event called

  • 1
    Just wondering is there any update on this? I'm having a similar issue. I want to redirect to a custom component after a record is created but can't figure out how to override being redirected to the record page. Any help much appreciated...
    – pduffy44
    Feb 1 '17 at 11:49
  • Hi @pduffy44, I didn't find out solution for that (override save button in force.createRecord), so I've solved my issue with the other solution. In stead of using force:createRecord, I made my own dialog (this could take time for lookup fields, validation ...) but this is the only way I could go at that time. Hope this help.
    – ted
    Feb 2 '17 at 5:03
  • salesforce.stackexchange.com/questions/223283/…. one post here did the trick, I have tried and it is working
    – Wayne Ni
    Dec 3 '20 at 2:15

This is the standard designed behavior of force:create record. There is no way to handle the redirection on click of Save button. If you want to do that you have to prepare a custom component for that.


There is an undocumented solution for this. Below is the js controller function that creates a new Contact record and redirects back from the record page to the initial page after a new record is created.

createNewContact: function(component, event, helper) {
    var windowHash = window.location.hash;
    var createEvent = $A.get("e.force:createRecord");
        "entityApiName": "Contact",
        "panelOnDestroyCallback": function(event) {
            window.location.hash = windowHash;

Where "panelOnDestroyCallback" is the hidden force:createRecord attribute. I know that's an ugly hack, but hey, if I had known this before I wouldn't have spent 50+ hours implementing a fully-custom multi-object 'createRecord' component with all the schema tricks, custom lookups, multipicklists etc.


In my case, I needed to refresh the whole page. So I used -

window.location.href = window.location.href;

instead of window.location.hash = windowHash;

It did the trick.

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.