+ Start a Discussion
AnidevAnidev 

visual flow lightning component redirect - A complete answer for this resolved question

Hi Team,

I posted a comment on this question - https://developer.salesforce.com/forums/ForumsMain?id=9060G0000005ohuQAA
, however didn't get a response hence posting a question.
If you can please help with the .cmp and .js code.

Thanks in advance.
Ani
Khan AnasKhan Anas (Salesforce Developers) 
Hi Anidev,

Greetings to you!

By default, when a flow finishes, a new interview starts and the user sees the first screen of the flow. To instead redirect the user to another page, build or install a local action that does so. Then add the action to your flow with a Core Action element. For example, local action can open a record, list view, or URL or to show a toast message. Or it can use the Lightning Console JavaScript API to close a console tab.

Please refer to the below links which might help you further with the above requirement.

https://automationchampion.com/2019/04/16/getting-started-with-lightning-flow-designer-part-4-need-to-redirect-a-user-to-a-new-record/

https://help.salesforce.com/articleView?id=flow_concepts_finish_override.htm&type=5 (https://help.salesforce.com/articleView?id=flow_concepts_finish_override.htm&type=5)

https://success.salesforce.com/answers?id=9063A000000pc67QAA

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
AnidevAnidev
Hi Khan Anas,

Really appreciate your response.
I have tried each one of those mentioned above - none of them working :(  
That is why posted on the forum.

This is the lightning component

design ---

<design:component>
   <design:attribute name="recordId" label="Record ID" />
</design:component

js ---

({    invoke : function(component, event, helper) {
   // Get the record ID attribute
   var record = component.get("v.recordId");
   
   // Get the Lightning event that opens a record in a new tab
   var redirect = $A.get("e.force:navigateToSObject");
   
   // Pass the record ID to the event
   redirect.setParams({
      "recordId": record
   });
        
   // Open the record
   redirect.fire();
}})

cmp ---

<aura:component implements="force:lightningQuickAction,lightning:availableForFlowActions">
   <aura:attribute name="recordId" type="String" />
</aura:component>

Flow picture attached.

Thanks and Regards,
Anidev

User-added image