Form value not retained in viewstate? How does it work?

I checked several posts such as https://www.outsystems.com/forums/discussion/33312/documentation-for-scope-of-web-page-variables/ but i am stuck at why the value of my combo box and input field with calendar widget get reset every time the flow reaches the END widget.


1) Start > Form.Valid (assuming all are correct) > Check if Date input is greater than today+3 days > Check if the combo box selection is not "N.A." (special value 1) or "VIP" (special value 2) > Create Person > Navigate to Home


1a) If Date is not greater than today + 3 days > Throw feedback message > End


1b) If Combo Box selection is "N.A." or "VIP" > Throw feedback message > End.


Whenever my user were to hit the issues in (1a) and/or (1b), the value get reset. For (1a), the value will always get reset to CurrDate(). I set CurrDate() as the default value whenever the page is first run in preparation. For (1b), the value always reset to select the first item in the combo box.

How do I force the page, on postback, to retain their original selection in the combo box as well as the input field?

Solution

Hi, if you could share your OML that would be easier for us to troubleshoot.

But a few questions:

1. Does your button work as Submit or Ajax Submit?

2. Are you resetting the default values in the preparation (setting the variable to CurrDate())?

3. If using Submit, and resetting the value in the preparation, then this would explain that behaviour. The preparation will run, resetting the values of your combo box and input fields. To avoid that, use an If with the condition: IsLoadingScreen() - which will be True only on the first run of the preparation.

4. If using Ajax Submit, are you refreshing the form? The calendar widget has an option to start empty, and another option for the initial date, are you using any of those options?

Solution

Dear Leonardo

Thank you for your post.

1. It worked as Submit.

2. You got this right. 

3. Yes this is what actually happened. IsLoadingScreen() is new to me, and it helps to know.

4. This is new to me too.

Now it all make sense. Hope this post can aid another newbie too :)