Introduction
In this article, I bring up a solution to when you want to merge multiple SharePoint lists. Rather, you can create a screen in Microsoft PowerApps, add all the fields of the SharePoint List, and use the Patch Function to update it.
Syntax
Modify or create a record in a data source
Patch( DataSource, BaseRecord, ChangeRecord1 [, ChangeRecord2, … ])
- DataSource – Required. The data source that contains the record that you want to modify or will contain the record that you want to create.
- BaseRecord – Required. The record to modify or create. If the record came from a data source, the record is found and modified. If the result of Defaults is used, a record is created.
- ChangeRecord(s) – Required. One or more records that contain properties to modify in the BaseRecord. Change records are processed in order from the beginning of the argument list to the end, with later property values overriding earlier ones.
Instance 1
For this, I have created four SharePoint Lists 1. List1, 2.List2, 3. List3, 4. List4 and added some text inputs fields and purpose are on one Input Screen User will give input for all four Share Point lists and it will save and update the value in all four records.
Create 4 different lists in Sharepoint:
- List1
- List2
- List3
- List4
Create columns in the above SharePoint List with the following names:
- In List1 create Columns 1a, 1b, 1c
- In List2 create Columns 2a, 2b, 2c
- In List3 create Columns 3a, 3b, 3c
- In List4 create Columns 4a, 4b, 4c
Challenge
"Update these four records simultaneously using one button click"
Refer my
article to create the Share Point List and to create columns in a Share Point List
Solution
Login with Office 365 your ID and open the Microsoft PowerApps using the following
link.
Choose Tablet layout:
Choose a Canvas app to start to design an app from scratch.
Adding the Data Source
From the top pane of the Microsoft, PowerApps screen click on View and then Data Sources, search for the Share Point list name
Then add the corresponding Data Sources:
Building the Screen:
Design and build the screen in this manner in PowerApps.
Insert Labels and rename them to add their Text property.
1a, 1b,1c for List1
2a,2b,2c for List2
3a,3b,3c for List3
4a,4b,4c for List4
Insert TextBox next to the above Labels for their corresponding Input rename the Textbox with their relative names.
Now add any type of different inputs in the TextInput fields and click on Submit.
On click function of Submit Code:
- Patch(List1, Defaults(List1), {
- Title: Now(),
- '1a': '1a'.Text,
- '1b': '1b'.Text,
- '1c': '1c'.Text
- });
- Patch(List2, Defaults(List2), {
- Title: Now(),
- '2a': '2a'.Text,
- '2b': '2b'.Text,
- '2c': '2c'.Text
- });
- Patch(List3, Defaults(List3), {
- Title: Now(),
- '3a': '3a'.Text,
- '3b': '3b'.Text,
- '3c': '3c'.Text
- });
- Patch(List4, Defaults(List4), {
- Title: Now(),
- '4a': '4a'.Text,
- '4b': '4b'.Text,
- '4c': '4c'.Text
- });
Now() is coded for when the user gives input.
When the user clicks Submit, all 4 records data will be updated at the same time.
Output
List4
The above images show the records of 4 Lists which are updated at the same time.
Instance 2
Let's take another example using Patch Function. On one PowerApps screen, we can insert multiple forms
Step 1
On the top pane of the Microsoft PowerApps Screen, click on Insert and then Forms
Click on Forms
Add the Data source from the right pane:
Now add three forms in a single screen and arrange them in order:
Add the code in the Submit Button to update the three forms simultaneously:
- Patch('Registration Form', Defaults('Registration Form'), Form1.Updates);
- Patch(Address, Defaults(Address), Form3.Updates);
- Patch('Project Details', Defaults('Project Details'), Form4.Updates)
Then play the app from the top right corner of the screen.
Output
The Forms will be updated at the same time
Conclusion
Merging of Share Point List is possible using one screen on Microsoft power apps and saving data using the Patch Function.
In this article, we learned about using the Patch function to update multiple records, along with arranging multiple Sharepoint Lists on one screen in different Forms.
Enjoy working with me! Thank you!