3

I've a Custom Lightning Component displaying a List custom object records.

On each data row, I've custom button to Edit the record.

On Edit click, I've fired following event:

var editRecordEvent = $A.get("e.force:editRecord");
editRecordEvent.setParams({
     "recordId": component.get("v.item.Id")
});
editRecordEvent.fire();

Now, this does open the Edit modal dialog for the record, but After we have Saved, it does not Refresh the list of record I have in the display.

Is there any way I can trap the Save event and reload my Component data after we Save any record from the list?

1

3 Answers 3

0

I am not sure exactly if this would work but you can take a look at the force:recordSaveSuccess event type. Here is a link to the documentation: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_recordSaveSuccess.htm

0

After providing you are using a custom component you can just set up a init method which is called when the component is loaded. When you save your record, you can fire the same controller method again.

If you need to redirect the user to the record, you use force:navigateToSObject:

$A.get("e.force:navigateToSObject").setParams({
    "recordId": recordId ,
    "slideDevName": "detail"
}).fire()

But if you just need to reload a record view, you use force:refreshView:

$A.get("e.force:refreshView").fire();
-2

I had the same issue. I was not able to Refresh the page after save but at least I can Redirect to the page where the records is created using location.href

var windowRedirect = window.location.href; // Current Page URL

var createEvent = $A.get("e.force:createRecord");
createEvent.setParams({
    "entityApiName": 'Custom_Object__c',
    "recordTypeId": RecTypeID, 
    "defaultFieldValues": {
        "Opportunity__c": oppId
    },
    "panelOnDestroyCallback": function(event) {
        window.location.href = windowRedirect; // Return to the page where the record was created
    }
});
createEvent.fire();
1
  • I did not downvote, but this approach seems certain to violate the LockerService paradigm, even if it is allowed. I would think proper lightning navigation would use force:navigateToUrl or something similar.
    – Adrian Larson
    Commented Jul 3, 2018 at 17:45

You must log in to answer this question.

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