0

I have a lightning component under a quick action on Account that is used for updating the record. After the update that changes the account record type, I want to open the record edit page.

   updateRecord: function(component) {
        component.set("v.errorMessage", null);
        var self = this;
        var action = component.get('c.doOnboard');
        var record = component.get('v.record');
        var recordId = component.get('v.recordId');

        record.Id = recordId;

        action.setParam('record', record);
        action.setCallback(self, function(result) {
                    if (component.isValid()) {
                        var data = JSON.parse(result.getReturnValue());
                        if (data.success) {
                             var navService = component.find("navService");
                             var pageReference = {
                                         type: 'standard__recordPage',
                                         attributes: {
                                             "recordId": recordId,
                                             "objectApiName": "Account",
                                             "actionName": "edit"
                                         }
                                     };
                             navService.navigate(pageReference);
                        } else {
                            component.set("v.errorMessage", data.message);
                        }
                    }
        });

        $A.enqueueAction(action);

    }

This solution works maybe half of the time. Rest of the times, instead of opening the edit page, it refreshes the whole page closing both the edit page and the quick action component, and staying on the view page of the record.

Any ideas why it happens or how to resolve it?

  • Can you please clarify that you have a Lightning component under quick action which will open record edit page of the particular record? Not able to understand "After the update that changes the account record type I want to open the record edit page." --? If after update it opens record edit page, what does the quick action do in the first place? – 7'7' Mar 21 at 10:15
  • lightning component is under quick action. It contains few fields that user must to complete and based on their value, the update will set new record type. After that I want to open the edit page of that record that will contain fields not available in previous record type. hope that clarifies it – Maciej Jaźnicki Mar 21 at 10:22

Your Answer

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

Browse other questions tagged or ask your own question.