4

I have a Lightning Component with a controller that uses e.force:editRecord, which I've added to a Flow after create record action. After saving the record on the editRecord screen, I would like to redirect the user to the sObject. The component works fine when I click on the quick action, launch the flow, and edit the record, and when I save, the edits are saved, but it refreshes to the edit screen. After editing and clicking save, I want the edit screen to disappear and redirect the user to the sObject. I've tried using e.force:navigateToSObject, but I can't get it to work. Is that even possible or how might I accomplish this?

Component

    <aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId,lightning:availableForFlowScreens,lightning:availableForFlowActions" access="global">
        <aura:attribute name="recId" type="String" />
        <aura:handler name="init" value="{!this}" action="{!c.invoke}" />
   </aura:component>

Controller

({
    invoke : function(component, event, helper) {
        var editRecordEvent = $A.get("e.force:editRecord");
        editRecordEvent.setParams({
             "recordId": component.get("v.recId"),
        });
        editRecordEvent.fire();
    }
})

Any way to do this with AfterRender?

({
    Redirect : function() {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
          "recordId": component.get("v.recId"),
        });
        navEvt.fire();
    }
})
1
  • any chance you found an answer to this, really really good question? Dec 16, 2020 at 18:03

0

You must log in to answer this question.

Browse other questions tagged .