web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Preserving Form Input ...
Power Apps
Unanswered

Preserving Form Input when using browser back button

(1) ShareShare
ReportReport
Posted on by 32

Hello,

 

I'm working on a Dataverse application which includes a form where a user would input values and may click on submit. 

We have a request from our client, for the input data to pre-populated if the user navigates away from this form and then uses the browser back button to return. I'm seeing some information about the use of global variables which makes me think that I can store the form values within a global variable and then use this to prepopulate the form when it loads. The other question is how to know that the user returned to the form through the use of the browser back button, rather than using the menu navigation.

 

I realize this is a very open ended question, but after searching this forum and the web for a considerable time, I decided to post my question. At minimum, I'd love to see some documentation that guides me on the use of global (or session state) variables within Dataverse applications. 

 

Thank you,

 

Anita

I have the same question (0)
  • akatakkar Profile Picture
    32 on at

    New find, this is potentially a way of preserving state:

     

    PowerApps-Samples/component-framework/ControlStateAPI/ControlStateAPI at master · microsoft/PowerApps-Samples · GitHub

     

    I need to determine if state is maintained when using the navigation and also the browser buttons. 

  • ivan_apps Profile Picture
    2,189 Moderator on at

    I’m not sure this would preserve state across pages. If this control stayed on the form perhaps but it definitely needs a place to store data.

     

    what I would suggest is perhaps using browser cookies. You might be able to set a cookie on the parent context and add to that context as people enter data into the fields you have. You would have several onchange events that trigger and keep the global context updated. When a user leaves the form without saving and returns, your JavaScript on load event would look to the global context to see if there is an object saved from before, read all the properties and re-add them to the form if the form is a new form. You’d definitely want to be careful not to overwrite existing form data or tie the global context to the record’s GUID.

     

    alternatively why not just enable auto-save and have it keep saving the form so you don’t have to do this workaround? Then the back button works by default to keep their data.

  • akatakkar Profile Picture
    32 on at

    Thanks for these suggestions. I don't believe auto save is an option at this point due to other customizations on the application, but your suggestion of cookies sounds like a good one. 

  • Shashank Bhide Profile Picture
    946 Moderator on at

    I wouldn't implement this requirement because dynamics OOB doesn't support this, you can try using following way though.

    1. assuming you're talking about an entity form where a record can be opened for editing or new record entry.
    2. you've to write JS on form onload event and determine whether it's a new form or edit form.
    3. if it's a new form (and this is the ugliest part) you have to write JS on each of the form controls (textboxes, lookups etc..) when you tab out of those controls, you've to park that information in browser session storage or local storage.
    4. if you manage to do above, then on form OnLoad event you can check if localStorage has any data and if yes, the populate that data on the form (again using XRM JS SDK)
    5. it'll be more easier to implement this on a completely custom screen.
    6.  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 633

#2
11manish Profile Picture

11manish 588

#3
Valantis Profile Picture

Valantis 457

Last 30 days Overall leaderboard