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 Apps
Answered

Model Driven Form

(1) ShareShare
ReportReport
Posted on by 54
Hi,
I have a custom page with a gallery that has filters, search, and sort. When a user clicks an item it navigates to a model-driven form:

Navigate(ThisItem, {Page: 'DataverseTable (Forms)'.Form})

When the user hits Back in the model-driven form, the custom page reloads and all filters/search/sort reset to default.
How do I preserve the custom page state when returning from the model-driven form?
Thanks!
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    3,571 on at
     
     

    The page reloads because navigating to a model-driven form breaks the custom page state 

    Save your filters before navigating:

    Set(gblSearch, SearchInput.Text);

    Set(gblFilter, FilterDropdown.Selected.Value);

    Navigate(ThisItem, {Page: 'DataverseTable (Forms)'.Form})

    Then in your custom page OnVisible, restore them

    UpdateContext({locSearch: gblSearch, locFilter: gblFilter})

     
    Vishnu WR
     
    Please  Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like 
     
  • Suggested answer
    11manish Profile Picture
    2,882 on at
    If users frequently navigate between a gallery and model-driven forms, I would recommend persisting the state in either:
    • URL parameters (simple and effective), or
    • Dataverse user preferences table (most robust and scalable).
    Unfortunately, there is currently no built-in mechanism that automatically preserves a custom page's filter, search, and sort state when returning from a
     
    model-driven form using the browser Back button. The state must be explicitly saved and restored.
  • Suggested answer
    Valantis Profile Picture
    6,341 on at
     
    To complete the implementation:
     
    Before navigating to the form, save all state to global variables:
    Set(gblSearch, txtSearch.Text);;
    Set(gblFilter, ddFilter.Selected.Value);;
    Set(gblSortColumn, varSortColumn);;
    Set(gblSortAsc, varSortAsc);;
    Navigate(ThisItem, {Page: 'YourTable (Forms)'.Form})
    In your custom page OnVisible, restore the state:
    UpdateContext({
        locSearch: gblSearch,
        locFilter: gblFilter,
        locSortColumn: gblSortColumn,
        locSortAsc: gblSortAsc
    })
    Then bind your search input Default to locSearch, your filter dropdown DefaultSelectedItems to the matching choice, and your sort variables to locSortColumn and locSortAsc.
    Global variables (Set) persist across page navigations within the same app session, so they survive the round trip to the MDA form and back.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Valantis Profile Picture
    6,341 on at
     

    Just wanted to check in and see if everything is working now. If you still need any help, feel free to let me know.

    Also, if the issue is resolved, it would be great if you could mark the answer as solved so others with the same question can find it easily.

     

    Thanks and have a great day!

  • husham86 Profile Picture
    54 on at

    Hello,

    Unfortunately, using global variables with Set() does not persist values when navigating from a custom page to a model-driven form. When users click the back button to return to the custom page, it reloads fresh and all variables are cleared. As an alternative, I added a text column in the Dataverse table to store the values. When users click the reset button for filters, it clears the values in that column. This is a temporary solution, but it has been working well so far. I’m sure there’s a better approach, but as I’m still new to this, this is the best solution I’ve been able to implement.


     
  • Valantis Profile Picture
    6,341 on at
     
    hm yes you are right global variables reset when the custom page unloads in MDA context. Your Dataverse approach works.

    To clean it up: instead of storing state in your main data table, create a small dedicated user preferences table with one row per user (filtered by User().Email). Write the filter state there on navigate, read it on OnVisible. Same idea, cleaner separation.

    This Dataverse preferences pattern is actually what Microsoft recommends for persisting state across MDA page navigations.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • husham86 Profile Picture
    54 on at
    Correct. I'm using a user table with a text column for variables to keep everything clean and make the variables a user specific 
  • Valantis Profile Picture
    6,341 on at
     
    That's exactly the right approach. User-specific variables stored in a Dataverse user table are clean, scalable, and survive page reloads and session changes. Good work figuring it out.

    If this resolved your issue, please mark one of the answers as the solution so others with the same problem can find it easily.
    Thank youu and have a nice weekend.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 392

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 271 Super User 2026 Season 1

Last 30 days Overall leaderboard