Do you ever use the patch function with the Power Apps Combo Box control? If not, this Power Apps Tutorial will guide you through how to work with patches using a combo box control to meet your business needs in a variety of scenarios, such as:
- Power Apps patch combo box value to SharePoint list
- Power Apps patch combo box selected value
- Power Apps patch combo box multiple values
- Power Apps patch combo box to SharePoint person field
- Power Apps patch combo box to SharePoint lookup column
- Power Apps patch combo box value to the collection
In Power Apps, there is a function Patch() that is used to add or edit a single record or a list of records from a data source. This allows you to change field values without affecting other properties. The patch can save data from multiple screens at the same time.
Continue reading to learn how to use the Power Apps patch function within the combo box control in the scenarios below.
Power Apps patch combo box value to SharePoint list
Here, we will see how to patch a combo box value to the SharePoint list from Power Apps. For this, we have prepared a SharePoint list named Workers having a title and a choice column (WorkMode) like the one below:
We have attached this list to a Power Apps canvas app. On that screen, we will add a text input to insert the title of the worker. Also, add a combo box control using the below expression on the Items property to display the work mode.
Items = Choices(Workers.WorkMode)
Where,
- Workers: The name of the SharePoint data source
- WorkMode: The name of the SharePoint choice column.
To patch the data from the combo box to the SharePoint list, add a button control to the respective Power Apps screen and inject the below expression on the button’s OnSelect property. So that when the user clicks on the button, the data will save in the SharePoint list.
OnSelect = Patch(Workers, Defaults(Workers),{Title:Txt_WorkerTitle.Text, WorkMode: Cmb_WorkMode.Selected});
Where,
- Txt_WorkerTitle: The name of the text input control
- Cmb_WorkMode: The name of the combo box control
Let’s save and publish the app. Play it in preview mode, then insert data and select a choice from the text inputs and combo box control respectively. (Ex: Smith, Hybrid)
Once we click on the Save button, we can see the items got patched in the SharePoint list like below :
This is how to patch a combo box value to the SharePoint list within the Power Apps.
Also read: How to Sort Combo Box Items in Power Apps
Power Apps patch combo box selected value
In the above example, we have seen how to patch a combo box value to the SharePoint list using a button control. Here, we will see how to patch a selected value from the combo box control to the SharePoint list without using a button control.
That means when the user selects any choice from the combo box control it will directly patch to the SharePoint list. To work with this scenario, we are going to use the above example of the SharePoint list as well as the canvas app and the following steps are :
- On the Power Apps screen, insert the below expression on the combo box’s OnChaneg property.
OnChange = Patch(Workers, Defaults(Workers),{Title:Txt_WorkerTitle.Text, WorkMode: Cmb_WorkMode.Selected});
Once we insert any data within the text input and select an item from the combo box control, we can see the selected item got patched from the Power Apps combo box control to Power Apps. (Ex: David, WFH).
We can see the outcome in the respective SharePoint list below:
This is how to patch combo box a selected item to the SharePoint list.
Check: Power Apps Cascading Dropdown Control
Power Apps patch combo box multiple values
Because the combo box allows us to select multiple values, we can patch those values to the SharePoint list. In this section, we will see how to patch the multiple values from the combo box control to the SharePoint list.
To implement this, we are going to use the above example of the SharePoint list. On the SharePoint list, set the toggle on the choice column(i.e., WorkMode) to “allow multiple selections.” For this, select the choice column > Column Settings > Edit > More Options > Allow multiple selection > Toggle On > Save.
To select multiple options, enable the ‘Allow Multiple Selections‘ property on the Power Apps screen’s combo box control.
To patch the multi-selected items from the Power Apps combo box control to the SharePoint list, insert the below expression into the button’s OnSelect property.
OnSelect = Patch(Workers, Defaults(Workers),{Title:Txt_WorkerTitle.Text, WorkMode: Cmb_WorkMode.SelectedItems});
Let’s preview it and insert some data in the text input as well as select multiple choices from the combo box control (Ex: WFH, WFO) like below:
We can see the multi-selected items got patched to the SharePoint list, once the save button was clicked.
This is how to patch the multiple selected values from the combo box control to the SharePoint list.
Have a look: How to Reset Power Apps Combo Box
Power Apps patch combo box to SharePoint Person field
Here, we will see how to patch a person field from the Power Apps combo box control to the SharePoint list. That means the user can select an item(Person’s name) from the Power Apps combo box control and patch that item to the SharePoint list. To work with this requirement, the following steps are:
Suppose, we have a SharePoint list named Workers having 2 columns such as Name (Person field), and WorkMode (A choice column) like below:
On the Power Apps screen, let’s add a combo box control to display all the employees’ names in the respective organization. For this, add the Office365Users connector to the Power Apps and insert the below expression on the combo box’s Items property.
Items = Office365Users.SearchUser()
Then, set the data layout under the fields (on the right-side properties panel) as below:
- Primary text: DisplayName
- Searchfield: Mail
Now, we can find all the employees’ names within the Power Apps combo box control.
Add a radio button to allow the user to select their preferred work mode. Insert the following expression into the radio control’s Items property to display the WorkMode options.
Items = Choices(Workers.WorkMode)
Where,
- Workers: The name of the SharePoint list
- WorkMode: The name of the choice column
To patch the items from the above controls to the SharePoint list, add a button control to the screen and place the patch query below the button’s OnSelect property.
OnSelect = Patch(
Workers,
Defaults(Workers),
{
Name: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpanderUser",
Claims: Cmb_Worker.Selected.Mail,
Department: "",
DisplayName: Cmb_Worker.Selected.DisplayName,
Email: Cmb_Worker.Selected.Mail,
JobTitle: " ",
Picture: " "
},
WorkMode: Rdo_WorkMode.Selected
}
)
Where Cmb_Worker and Rdo_WorkMode are the names of the combo box and radio control names respectively.
Let’s preview the app and select data from the combo box control as well as the radio control. (Ex: Sonam Subhadarsini, Hybrid).
Once the button is clicked, we can see that both items are patched within the SharePoint list.
This is how to Patch People Field from Combo Box to the SharePoint list.
Check out: Power Apps combo box with Office 365 users
Power Apps patch combo box to SharePoint lookup column
Here, we will see how to patch a combo box item to the SharePoint lookup column. The following steps are:
- We have created a SharePoint list named Organizer having 3 columns such as Title, ID (Default), and Organizer ID (Number type field) shown below:
- Also, we have prepared another SharePoint list named Events having a Title (Default column), and 2 lookup columns.
- The first lookup column named Organizer used the data from the Title field of the Organizer list(i.e, from the first SharePoint list).
- The second lookup column named ID_Organizer used the column data of the Organizer ID from the Organizer list.
- By default, another lookup column will be created in the SharePoint list having lookup data from the ID of the Organizer list. i.e., Organizer:ID.
This is how the entire Event list looks like below:
- Next move to the Power Apps to create our app as per the scenarios. On the Power Apps screen, let’s add a text field to insert the event’s title. Again, add a combo box control to display the choices of the organizer. For this, use the below expression on the combo box’s Items property.
Items = Choices(Events.Organizer)
- To patch the data, add a button control to the screen and insert the below formula on the OnSelect property.
OnSelect = Patch(
Events,
Defaults(Events),
{
Title: Txt_Event_Title.Text,
Organizer: {
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id: Cmb_Organizer.Selected.Id,
Value: Cmb_Organizer.Selected.Value
}
}
)
Where,
- Title: The name of the SharePoint column (i.e., From the Event list)
- Organizer: The name of the lookup column (i.e., From Event list)
- ‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”: While working with patch a lookup column via Power Apps, we need to use this mentioned connector.
- Id, Value: The Id and value of the custom column from the Event list
- Cmb_Organizer: The name of the combo box control
- Txt_Event_Title: The name of the text input control
- Let’s save the app and play it in preview mode. Insert data in the text input as well as select an item from the combo box control. (Ex- Stock Invest, Microsoft).
- Once we click on the save button, the data got patched from the combo box control to the SharePoint lookup column as well.
This is how to patch a PowerApps Combobox to the SharePoint LookUp column.
Check: How to Filter Power Apps Dropdown Control
Power Apps patch combo box value to the collection
Here we will see how to patch a combo box value to a collection within the Power Apps. When the user selects an item from the combo box control and clicks on the button, the desired items get patched within the collection.
Suppose, we have created a collection named CollProject having headers like ProjectName, and Technology on the Power Apps screen’s OnVisible property.
OnVisible = ClearCollect(collProject,{ProjectName: "Project1", Technology: "Python" })
Let’s add a vertical gallery to display the collected data the gallery like below:
Next, add a text input and a combo box control to the screen. On the combo box’s Items property, insert the below expressions to display the items for Technology.
Items = ["Python", "SharePoint", "Power Apps"]
To patch the selected items from the combo box to the collection, add a button control and insert the below expression on the OnSelect property.
OnSelect = Patch(collProject, Defaults(collProject),{ProjectName:Txt_ProjectName.Text,Technology:Cmb_Technology.Selected.Value});Reset(Txt_ProjectName); Reset(Cmb_Technology);
Where Txt_ProjectName and Cmb_Technology are the names of the text input control and combo box control respectively.
Let’s preview the app, then insert a project name in the text input and select technology from the combo box control.
When we click the Save button, we can see that the item has been patched in both the gallery and the collection, as shown below:
This is how to do patch a combo box value to a PowerApps collection.
Conclusion
From this Power Apps tutorial, we learned all about how to perform patch function using a Power Apps combo box control based on different types of scenarios such as:
- Power Apps patch combo box value to SharePoint list
- Power Apps patch combo box multiple values
- Power Apps patch combo box selected value
- Power Apps patch combo box to SharePoint person field
- Power Apps patch combo box to SharePoint lookup column
- Power Apps patch combo box value to the collection
Also, have a look at the below Power Apps tutorials:
- How to Work With Power Apps Dropdown Blank Values
- How to Remove Duplicates in Power Apps Dropdown
- How to Set Default Value in Power Apps Dropdown
- Power Apps Dropdown Control with SharePoint
- How to disable Power Apps date picker
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Out audiences are from the United States, Canada, United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a SharePoint MVP(8 times), check out My MVP Profile. I have also worked in companies like HP, TCS, KPIT, etc.