One of the most desired features in Salesforce Flows is the ability to redirect users to newly created records. For instance, when a record is created via a screen Flow, redirecting users seamlessly enhances their experience. The ideal solution should be:
- Reusable: Once created, it can be used in any new Flow without the need for redevelopment.
- Easy to Use: Avoid creating external addresses or links every time a new record is created. The solution should be accessible directly from within a Flow via an Action component.
Let’s create a fast and straightforward solution to redirect users to any record from a Flow by developing a new Action using a Lightning component in Salesforce.
Step 1: Open the Developer Console and create a new Lightning Component.
Step 2: In the component section, add the following code:
<aura:component implements="force:lightningQuickAction,lightning:availableForFlowActions">
<aura:attribute name="recordId" type="String" />
</aura:component>

Step 3: In the controller section, add the following code:
({ invoke : function(component, event, helper) {
var record = component.get("v.recordId");
var redirect = $A.get("e.force:navigateToSObject");
redirect.setParams({
"recordId": record
});
redirect.fire();
}})

Step 4: In the design section, add the following code:
<design:component>
<design:attribute name="recordId" label="Record ID" />
</design:component>

Step 5: Save all components, close the Developer Console, and ensure everything is properly configured. As per Salesforce documentation, this Action is now ready to use in a Flow.
Step 6: Create a Flow for record creation. Add an Action component, search for your newly created Action, and configure it. Simply set the input value (recordId) for the desired redirection and save the Flow. Once the Flow interview is complete, users will be redirected to the specified record – such as the newly created one.


