Skip to main content

Notifications

Power Apps - Microsoft Dataverse
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

Categories:
  • Shashank Bhide Profile Picture
    Shashank Bhide 932 on at
    Re: Preserving Form Input when using browser back button

    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.  
  • akatakkar Profile Picture
    akatakkar 32 on at
    Re: Preserving Form Input when using browser back button

    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. 

  • ivan_apps Profile Picture
    ivan_apps 2,187 on at
    Re: Preserving Form Input when using browser back button

    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
    akatakkar 32 on at
    Re: Preserving Form Input when using browser back button

    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. 

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,526

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,907

Leaderboard

Featured topics