Salesforce Fact #985 | Exit flow from any screen in screen flow
Suppose we have a requirement to let the user exit from any of the screen in screen flow.
We can use the FlowButtonBar component from UnofficialSF to implement this. However, if we want to go with the out of the box approach, here is how we can achieve it.
We can create an LWC which will be embedded in each of the screens and will have an exit flow button. It will have an @api var which is set on click of confirmation from the user and sent back to the screen flow. Based on this value, we can add a decision check to find out whether user has opted to exit the flow and can route the user to the exit. Also, on confirmation from the user, we call the FlowNavigationNextEvent to proceed to the next element in the flow.
One tricky thing is if the screen has outstanding validation errors then it won't move to the next screen. So, when the user opts for exiting the flow, we hide the existing inputs and then moves the user to the exit path.
Attached are the screenshots.






Comments
Post a Comment