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 / Save button submit for...
Power Apps
Answered

Save button submit form defaults to first record

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

  I have a forecasting app for sales reps and right now they can go into my app and select the account they want to forecast for.  When they select that account it brings up my 2023 forecasting form page.  The reps input their data and once completed they hit the save button which has the command onselect "SubmitForm('2023 Forecasting Form')".  The problem I'm running into is once they hit save the form defaults back to the first record of the list instead of staying on the record they chose.  How can I get the form to stay on the same record after clicking the save button?  

 

Thank You

Categories:
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    My guess is that you are using a gallery and in the forms item property you have gallery.selected

     

    If that is correct then you can solve the issue by changing the OnSelect property of the gallery to 

    Set(varSelectedRecord, ThisItem)

    and then change the form Item property to varSelectedRecord

     

    This way if the gallery gets refreshed and the gallery.selected changes your varSelectedRecord will still contain the originally selected item.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Jeff_Thorpe   

     

    You're correct that I'm using a gallery to display the accounts for them.  I input the formula you suggested and when I try to navigate from the gallery to the form it doesn't do anything.  I have a next arrow that has OnSelect Select(Parent)  Would this have anything to do with why it's not working?  I do have in the form onsuccess Refresh(2023 Forecast) I put this in there so when the rep clicks save the form would should the data they just input.  

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    If the arrow in the gallery has the OnSelect set to Select(Parent) then it should execute the formula in the OnSelect of the gallery because that is its parent. If you are in the design studio then you can hold down the Alt key and with the mouse click an item in the gallery. After you do that click on View in the menu bar and click Variables. From you should be able to see if the variable got set. If the variable got set then we know the issue is on the form side.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Jeff_Thorpe   Thanks for the info but the variable did not get set.  The only variable I have in that view after selecting the record with the alt key pressed is a Sortdecending boolean.  Below is my items formula in case that could be causing the issue from temp adding and deleting columns for the filter.  I've also included a screenshot of the formula I've entered on the gallery screen.

     

    Nate167_0-1641500833104.png

     

     

     

    With({_items:
    Filter('2022 (WRFP-3)',Or(
    'GWA ID L/U:Account Manager_TXT'.Value=CurrentUser,
    'GWA ID L/U:Sales Manager_TXT'.Value=CurrentUser)
    )
    },
    DropColumns(
    Search(
    AddColumns(_items, "_billIDName", 'GWA ID L/U:BillingID_Name'.Value
    ), 'Search Box'.Text, "_billIDName"),"_billIDName"))

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    This is strange. The only code in the next arrow OnSelect is Select(Parent)? For troubleshooting purposes you code replace the Select(Parent) with Set(varSelectedRecord, ThisItem). 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Jeff_Thorpe    When I run the app it will not move to the forecasting form from the gallery.  Below are screenshots of all the changes I made for the varselected info.  

     

     

    Nate167_0-1641842227966.pngNate167_1-1641842248567.pngNate167_2-1641842283239.png

     

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    Is the gallery and form (Forecasting page) on different screens?  If so, then you will need some additional code to navigate to the form screen.

     

    OnSelect:

    Set(varSelectedRecord, ThisItem); Navigate('ScreenName',ScreenTransition.None); EditForm('FormName')

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Jeff_Thorpe   Yes sorry, they are on separate pages.  I added the code you suggested and it now navigates to that record in the form but after about 10 seconds the form defaults back to the first record in the gallery.  In the form I do have OnSuccess set to Refresh('2022 Forecast') so that when a user saves their data it will refresh and show the saved information.  Could that be causing the form to default to the first record?

  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    The refresh will cause the gallery.selected to changed but varSelectedRecord shouldn't change unless someone clicks on the gallery row. Is there any other code in the OnSuccess or the OnSubmit?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ahh sorry I found out what I did wrong.  I forgot the account name area of my forecasting page was it's own form separate from the forecasting fields.  Thank you for all of your help, it is very much appreciated!!

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard