Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

How to code last submit in a dropdown?

I'm new to power apps and just trying to code a drop down to return last submittedvalue on newform  not sure how to and help would be much appreciated. The app I'm working on will create 20 to 30 records a day with the same block number. So I need the dropdown value to defualt to last selected value  when submitted on new form 


What I am looking for is to save the selected value say 205 for example in tye dropdown newform. So tye submitted form would be 205 and the new form would start with the 205 selection already selected in the dropdown. Is there A code that can do  that ?  



Yes try like this.


Presuming a Form called Form1 and a button called Button1 and a data source called List01 (such as a SharePoint List, for example):


Form1 DefaultMode





Form1 Item


//Instead of List01 above, use the name of your SharePoint List or data source.



Form1 OnSuccess









Button1 OnSelect





This should work, and the New form after submit, will have all the previous values based on the last submitted record, but still be a new form mode. After the next submit, it should create a brand new record.


If the above does not work, properly i.e. for example, if for some reason it just keeps editing the same last submitted record over and over again, it could be because the part where Patch of Blank() value for ID, might not work and not actually remove the ID (thus editing the same last submitted record over and over again), unless a specific setting is turned on in the app called Formula-level error management . So if it does not work, try these steps as well below first:


1. Click on Settings



2. In the modal, click on Upcoming Features -> Preview ->  Formula-level error management - set this toggle, to "On"


3. Close this modal.

4. Save and Publish the app.

5. Close the whole Power Apps editor.

6. Go to, select the right environment, find your app for editing, and open it up for editing. If you just made this app recently and it's missing from the list for some reason, just try making a new blank app, and the one that is missing might now appear in the list.

7. Try the app now and see if it works.


This setting has been around for quite a long time, it is often turned on for this kind of scenario, the fact that it is labeled "Preview" may not be so much of a concern, I doubt the feature is going away in the future. While that is technically subject to change, I am not able to think of a better way to accomplish your scenario. First try and see if it works with the Formula-level error management setting off (the default). If it does, then great. If it does not (and I suspect that it might not), this setting Formula-level error management  may have to be set to On for this solution to work properly. Please note that after turning it on, it may be necessary to close and reopen the app for editing as stated in the above steps, if it is still not making a new record on each submit, so that the setting could fully take effect.


See if it helps @RoB-E 

I did tye steps and also turned on tye function in settings. I'm getting this error ? I have also tried added the ID data card to my app but it still says same error.

I did fix the form name after sending the last message to EditForm1 in the code. I still recive same error message?



The names of the form and the name of the column is for example only.


Maybe you are not using a SharePoint list. Instead of ID, put whatever is the column or field that uniquely identifies each row over there.


Even if you  are using a SharePoint List, the ID column may have been renamed for some reason in your List, or it is a custom unique column, and may have some other name. than "ID". Check if this might be the case for you, and use this as the name of the column instead of "ID".


If you are sure that you do not have any column or field that uniquely identifies each row in this data source, you may be able to remove the Patch part altogether, and it might just work like that anyway. However, in most cases, there is a column that contains the Primary Key, or in other words, the field that has a unique value, which uniquely identifies the row for that "table". If this unique field value is left in there and not blanked out, even if the form is on New, then it will either edit the same record over and over again on the next submit, or throw an error from the data source side on the next submit that the unique value already exists, and then just refuse to create the record altogether and just show that kind of error of the record with that unique value already existing.


If you are sure you have no Primary Key, you could try removing the Patch portion. However, I recommend you leave it there, figure out what is the Primary Key column, and use that as the name of the column instead of "ID".


See if it helps @RoB-E 

Thank you this did work. i first tried it on a new form page and it worked. I then went back to my app and realized I needed to remove Reset(Form) & EditForm1(NewForm) from my Onselect. its working fine now thanks again. I do have one more Question. for all the other Fields I want Blank after Submit I changed  the Default To "" is that ok? it seems to work just not sure if I should be doing it another way 



You can try to use Blank() for Default instead of "" to be more accurate - especially since you may already be using Blank() now in the Patch statement I gave to make the ID field blank in the new record after submit.


 It may be required to have Formula-level error management turned on as I mentioned before, to use Blank() values (especially to patch out the ID to a Blank value).


If it is working better or more consistently for you with "", or if you just prefer it, then using "" for Default may be acceptable as well. I recommend to use Blank() but if you prefer it, you may use "" instead, but make sure to carefully test it, some cases may require Blank() to be there and not "" to signify a blank value for a field.

Ok now that all of that is working I noticed I have duplicates showing up in my share point list is there  away to stop that ?


If the button is pressed again and again, it will create new records with the same values, this is by design of what you requested. They definitely should be different records though with a different unique ID if you check the SharePoint List.

If you want one or more fields to always be different, try using a function like Rand(). You could also try accessing the LastSubmit directly after the OnSuccess, getting the unique ID, and Patching it to another field - although I am unsure why that would be a good idea - the unique value is already there generated automatically, it may be better to simply edit the SharePoint List view, reveal the unique ID, and notice they really aren't "duplicates".


Whatever makes it look like a "duplicate", you could perhaps blank out more fields such as specific fields that should not be pre-filled for instance.




//change "SomeOtherFieldToBlankOut" and "YetAnotherFieldToBlankOut" to what makes sense for you for what you want to not use the last submitted value, but be blank instead, and have how many or how few of those you want.


You can test by using Rand() which should make it pretty obvious they're not duplicates, then try instead to do whatever makes more sense for the field(s) instead.


In case there may still be some issue, could you clarify what you mean by noticing that you have duplicates?

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,226)