In this PowerApps Tutorial, We will see what is LastSubmit() function in PowerApps, Why we will use this function, and how PowerApps LastSubmit() works on the PowerApps screen or app.
Also, We will discuss these below topics those are related to the PowerApps LastSubmit() function:
- How to use lastsubmit in PowerApps
- PowerApps lastsubmit.id
- PowerApps lastsubmit not working
- PowerApps patch last submit
- PowerApps edit form lastsubmit
- PowerApps sharepoint list submit
PowerApps lastsubmit()
- Before going to start anything related to the PowerApps LastSubmit function, a question maybe comes to your mind that, Does really the LastSubmit() function helps to display the last record or last item that was submitted to the data source?
- Coming the answer to this question is, Yes you can use the PowerApps LastSubmit function to retrieve the last item submitted during the current session.
- The PowerApps LatSubmit() is a property of the Edit Form. It can not communicate with the data source and therefore it is not affected by when multiple users submit nearly simultaneously.
- There are three below important points I can tell you shortly:
- This property applies only to the Edit form control.
- If the data source automatically generates or calculates any fields, such as an ID field with a unique number, the LastSubmit property will have this new value after SubmitForm successfully runs.
- The value of this property is available in the OnSuccess formula. This confirms the last successfully submitted ID is stored in the Edit Form properties.
You may like, PowerApps First, FirstN, Last, and LastN functions.
How to use lastsubmit in PowerApps
Here, by taking a simple scenario, We will see how to use PowerApps LastSubmit function easily. Refer to these below steps to do so.
Example – 1:
- The below screenshot represents the SharePoint List named Customer Care Report Details where the submitted records will save.
- This list has these many columns (with different data types) like Title, Customer Care Report For, Plot Number, and so on.
- The below screenshot represents the PowerApps Edit form that helps to submit a new item or record into that specific SharePoint list.
- The DataSource of the Edit form is the SharePoint List i.e. Customer Care Report Details.
- Here what I want to do is, I will insert a Label that will help to display the last submitted item in PowerApps.
- To do so, select the Label control and apply this below formula on its Text property as:
Text = "The last record that you submitted is: " & Form1.LastSubmit.'Customer Name'
Where,
- Form1 = PowerApps Edit Form name
- Customer Name = This is one of the column names from the specified SharePoint list. This helps to get the last customer name that you have submitted currently
- Now Save and Preview (F5) the app. Enter the field values and click on the Submit button. When you will click the button, then you can see the last customer name in the label control as shown in the below screenshot.
- Also, you can see the submitted item has been stored in the specified SharePoint list as shown below.
Example – 2:
- In this example, We will see how to retrieve the last submitted item details using the PowerApps LastSubmit function.
- The Last retrieved item will display on the PowerApps Display Form and the DataSource should be the SharePoint List name.
- To do this, Insert a PowerApps Display Form and set this below formula on its Item property as:
Item = Form1.LastSubmit
Where,
Form1 = PowerApps Edit Form name
- Save and Preview (F5) the app. Enter the field values in the edit form and click on the submit button. Once you will click, you can view the last submitted item details in the display form as shown in the below screenshot.
This is how to use lastsubmit() in PowerApps.
Also, check out, PowerApps CountRows function.
PowerApps lastsubmit.id
In this topic, We will see how to retrieve the ID of the Last submitted record or item using the PowerApps LastSubmit function.
- Suppose you want to get the ID of the last submitted form within a new form of your app. Then the Editform.LastSubmit formula would return the last successfully submitted record.
- You can access this property value within the OnSuccess property of the Edit Form.
- If you will open a New form within your app, then the Edit form would be reset and at the same time, the Editform.LastSubmit.ID formula would return empty.
- To do this, Insert a Label control and apply this below formula on its Text property as:
Text = "The last record that you submitted is: " & Form1.LastSubmit.ID
Where,
Form1 = PowerApps Edit Form Name
- Save and Preview (F5) the app. Enter the field values and click on the Submit button. Now you can see the submitted ID will visible in the Label control as shown below.
- Similarly, you can also take a try with the following formula to get the last submitted form data (a record) within your app i.e.: [As I have applied this formula on Label’s Text property]
Text = Last('Customer Care Report Details').ID
Where,
‘Customer Care Report Details’ = SharePoint List name
This is how to use PowerApps lastsubmit.id to get the id of the last item.
Read Power Apps List Box Control
PowerApps lastsubmit not working
- In some cases, While working with the PowerApps LastSubmit function, you may experience that when you are trying to get the ID of the last submitted item (EditForm.LastSubmit.ID), this formula is giving an empty result to you. At the same time, you will think that the PowerApps lastsubmit function is not working properly.
- To clear this type of issue, follow this simple scenario that why you are getting an empty result and how you can solve this issue by using the PowerApps LastSubmit function. Let’s discuss these below important points.
- When you want to get the ID of the last submitted form from your app, in that case, you could consider taking a try to store the last submitted form as a Collection within your app, and then you could reference the Editform.LastSubmit property value through the collection.
- Let’s do this example. Select the PowerApps Edit form and apply this below formula on its OnSuccess property as:
OnSuccess = ClearCollect(LastSubmittedItem,Form1.LastSubmit)
Where,
- ClearCollect = This is used to clear all the records from the Powerapps Collections and add a new record or collection into it.
- LastSubmittedItem = You need to specify a PowerApps Collection name
- Form1.LastSubmit = This will help you to retrieve the last submitted item from the edit form.
- Now you need to reference the ID value of the last submitted form within your app using the following formula: (To test this, I have taken a PowerApps Gallery Control and applied the below formula on its Items Property)
Items = LastSubmittedItem.ID
Refer to the below screenshot.
- Save and Preview (F5) the app. Enter the fields in the edit form and click on the Submit button. Once you will submit the item, then the Gallery control will display the last submitted item ID as shown in the below screenshot.
PowerApps patch last submit
Here we will see how to work with PowerApps Patch last submit function.
- In this scenario, I am using a PowerApps Edit form to submit the item to the specific SharePoint list. At the same time, I want to use the patch function to update a field of the last submitted item. Both Submit and Patch functions should be used from the same button only.
- In this case, most of PowerApps users (new users) are getting confused that: “Is it really possible to use the PowerApps Submit and Patch function from the same button control?”
- Coming the answer to this question is, Yes, you can perform multiple actions by clicking only one button. To do so, you just need to use a “;” to connect with two formulas. Follow this below example to submit a form and update one field of one item by clicking a button.
- Select the Submit button from the PowerApps Edit form and apply this below formula on its OnSelect property as:
OnSelect = SubmitForm(Form1);
Patch(
'Customer Care Report Details',
Form1.LastSubmit,
{'Customer Care Report For': "Airtel"}
)
Where,
- Form1 = Edit form name
- ‘Customer Care Report Details’ = SharePoint list name
- ‘Customer Care Report For’ = This is the SharePoint Column name where I will update the new value of the last submitted item
- “Airtel” = This is the string that I have specified to update
- The above code specifies it will submit the item into the specific SharePoint list and as well as update the field by a given value (“Airtel”) of the last submitted item.
- Now Save and Preview (F5) the app. Enter the record and click on the Submit button. As you can see, I have specified the value as “Vodafone” in the “Customer Care Report For” field.
- But once you will click on the submit button, the field value will be changed to Airtel (as I have specified in the above formula) in the SharePoint list.
- Go to the SharePoint list i.e. Customer Care Report Details. You can see the new Item has been created and the value has been updated with Airtel as shown in the below screenshot.
- The next time, When you will add a new record, then also, By default the “Customer Care Report For” column value will update with the value of “Airtel“, even if you will not enter this field value for any user.
PowerApps sharepoint list submit
In this topic, We will see how to store an item to a SharePoint list using the PowerApps Edit Form and as well as a Submit button control.
- Suppose your app is having a PowerApps Edit Form and a Submit button. When the user will Enter the field values (in the Edit form) and click on the submit button, then that particular item will save into the specific SharePoint list.
- To do this, you can apply this below formula on Button’s OnSelect property as:
OnSelect = SubmitForm(EditForm1)
Where,
EditForm1 = PowerApps Edit Form Name
NOTE:
One thing you must remember is, you must need to connect your Data source to the app. As you are saving the item in the SharePoint list, So you need to create a connection, Connect the SharePoint data source and add the specific SharePoint list to your app.
- Below is the link that describes more details about how you can use PowerApps Edit Form, a Submit button, and how an item can be stored in a SharePoint list.
Also, you may like these below PowerApps Tutorials:
- PowerApps AddColumns Function with Examples
- PowerApps Patch Function with examples
- PowerApps ForAll Function with examples
- PowerApps if statement with examples
- PowerApps Replace Function with examples
- PowerApps Employee Directory
- PowerApps Pen input control (PowerApps signature)
- PowerApps SharePoint Lookup Column + PowerApps Dropdown Example
- How to add PowerApps app to Microsoft Teams – Step by Step
- PowerApps Barcode Scanner – Detailed tutorial
- PowerApps Examples – COVID 19 Self Declaration form
- How to build multilingual app in PowerApps
In this PowerApps Tutorial, We saw how to use LastSubmit() function in PowerApps. We saw PowerApps lastsubmit() function with a few examples.
Also, We discussed these below topics those are related to the PowerApps LastSubmit function:
- How to use lastsubmit in PowerApps
- PowerApps lastsubmit.id
- PowerApps lastsubmit not working
- PowerApps patch last submit
- PowerApps edit form lastsubmit
- PowerApps sharepoint list submit
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
Great job! Very helpful
hi, when I create a collection using the lastsubmit it is empty,
for instance
Collect(Pass, {PassID: Form1.lastsubmit.id, Name: “”, Description: “”})
this is returns other values except the id.
i don’t want to create the ID as a standalone collection. I want the values all together but the last submit is always empty.
Please I’ll be really grateful if you could tell me how to make the lastsubmit id show in a collection with other columns.
I also noticed that it’s not just the lastsubmit id, any other value from the last submit doesn’t show up in the collection. it’s always blank.