The flow documentation is littered with this 'tip' but has no examples of what specifically to do. (bold is mine, for emphasis)

By default, screen components that require Lightning runtime have no memory. If a user enters a value, navigates to another screen, and returns to the component’s screen, the user-entered value is lost. To enable a flow to remember the value of an attribute, set the attribute. The flow stores the value automatically. If you store values manually, store the attribute’s output value in a variable.

Can someone explain exactly what the right way to 'set the attribute' is? I have pulled this off in various ways that seem to work, and curious if there is some learning here as to the best way to do this. The sentence afterwards further compounds my confusion by stating that 'the flow stores the values automatically' - so does this mean we no longer need to do anything and its all magically fixed?

A few selected instances of this tip (pretty much all component documentation) - address component - toggle

1 Answer 1


I agree that how it works is a bit confusing. I've done a bit of testing and I think this is how it works. However I have only tested this with the address input field, so please be aware that other elements may behave differently.

When you switch between screens all the element values are discarded. You effectively return to the screen as it was when you first loaded it. Sometimes this is desired behavior because it forces the user to reconsider everything on the screen. At other times it's annoying. (Let's say you've input an address and made a typo. You click back and the whole address is gone.)

When you want to remember the values, there are two situations that may be relevant.

1) You only want to use the values of the elements only within that specific flow screen. You use them for instance to toggle the visibility of other parts of the screen. If you still want the flow screen to remember the input value, then you need to set an input attribute for that screen element. Just the act of setting a value there is enough to make sure the flow will remember the user input when they click back. This solution requires that you deselect the manual variable assignment checkbox. I just tested this with an address element and what you put in doesn't seem to matter. It can be a variable (it won't be changed by the screen element). It can be a normal text string. Or it can even be a space or a {!$GlobalConstant.EmptyString}.

2) Often you will want to use the user input in other elements of your flow. In that case you will need to use the manual variable assignment option. However, if you still want the flow to remember the values if you click back, then just setting the manual variable assignment is not enough. You stil need to set the input attributes.

However, and this is odd, it doesn't seem to matter much what you put there. I have used three {!$GlobalConstant.EmptyString} in the input attributes, and put the three address fields in the same output variable and when I clicked back it had still remembered the proper values of each field. Of course one shouldn't do that in a real flow.

  • wow interesting, never thought putting emptystring as the input value would do that! maybe that is what they mean by 'set'?!? i've generally been assigning the value to a variable or sobject variable and then also setting that variable as default value for component, but things get cluttered or clunky pretty fast.
    – gorav
    Apr 22, 2020 at 13:43
  • Giving the field any type of input value is indeed setting the attribute. For inputs this can be a variable or text string and for output you can only use variables. Apparently on the backend it doesn't matter much what you put in as long as you put something in. As soon as you do that the attribute is set and the value will be automatically remembered if the user clicks on the back button.
    – Kasper
    Apr 22, 2020 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .