function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Itzik Winograd 7Itzik Winograd 7 

Listen to Flow Navigation Events on LWC

Hi
I need to perform an action on a LWC component when the flow navigates to Next/Finish. Since this component is part of a screen, I cant add my own navigation buttons on this component.
So, Is there any way to listen to the flow's native Navigation events?
Or, the only solution is to override the footer and add my own navigation buttons and use c-pubsub to perform an action on the mentioned component?
Thanks in advanced!
 
Best Answer chosen by Itzik Winograd 7
AnudeepAnudeep (Salesforce Developers) 
Hi Itzik, 

You should be able to use the Validate hook to accomplish this (discussed here and here). If you add it to your LWC, you'll get called each time something attempts to transition out of the flow screen. Most components that use this use it to carry out validation and potentially block the transition, but you could use it as a simple notification. I hope this helps

Anudeep

All Answers

AnudeepAnudeep (Salesforce Developers) 
Hi Itzik, 

What challenges do you have in using FlowNavigationNextEvent and FlowNavigationFinishEvent events? Do they not serve the purpose in your use case? 
Itzik Winograd 7Itzik Winograd 7
Hi Anudeep, Thanks for your reply.
I have X separated and customized upload-file components on the flow screen, as well as some regular/declarative input fields.
I need to submit the files on Next/Finish. So if I had an option to "listen" inside these X components to the general Next/Finish events it would be terrific. Can I do that? And if I do - How?
If I can't listen to them then I'll have to override the Next/Finish buttons with my own and then I could use pub/sub to submit the files in these x sibling components.
AnudeepAnudeep (Salesforce Developers) 
Hi Itzik, 

You should be able to use the Validate hook to accomplish this (discussed here and here). If you add it to your LWC, you'll get called each time something attempts to transition out of the flow screen. Most components that use this use it to carry out validation and potentially block the transition, but you could use it as a simple notification. I hope this helps

Anudeep
This was selected as the best answer
Itzik Winograd 7Itzik Winograd 7
Thanks, Anudeep!
It does the trick.