1

I have very specific flow which works in a loop. Everything is working if user use only next button. But then... back is coming.

My scenario

Screen 1(invokes loop) -> Screen 2 (Loads already existing data based on value selected on screen 1). User click back button -> Screen 1(everything is still ok) User selects another value which should be displayed on Screen 2 and clicks Next -> Screen 2 Value from first iteration is retained.

Same behavior is observed using standard input fields, custom LWC components which are lightning-inputs BUT for example standard display text is displaying CORRECT value.

My assumption is that this screen component is somehow hard-cached and whatever I'm trying to do (clearing data using assignments, I was trying to copy values to another variables in a flow, I've even used formula which was essentially a copy of a variable) it always show old values but only in inputs.

Any idea? How can I overcome this issue?

Yeah I know such a loop is not a good idea from the start but I don't have a choice right now.

3
+50

This is the expected behavior for Flow screen components.

Text fields in flow are optimized for a case where the value may need to be initialized to a default value, but once the user enters something else, the text field should not be reset.

For lightning component based screen flow inputs (including the "standard" inputs that are built/delivered by Salesforce out-of-the-box as lightning components), the behavior will be the same except for the case where an attribute has either its input mapped, or its output mapped, but not both or neither. Confusing? Yeah. Probably. But that's how it works.

For your custom LWCs, you can work around this by having separate "inputValue" and "outputValue" attributes, then only mapping an input for the "inputValue" attribute and manually assigning the output to the "outputValue". This will force the component to recalculate every time the screen is visited.

Alex Edelstein goes over this in painstaking detail on his blog here:

Optimizing Lightning Component Inputs and Outputs in Flow Screens

Also, it is worth noting that in my Spring 21 preview org, I see a new Advanced option that would allow you to set this behavior explicitly rather than implement the workaround I described. Safe harbor probably applies, but it looks promising:

Revisited Screen Values

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.