A few days ago, I developed a leave management application for Power Apps. In it, employee leave requests undergo two-level approvals, so I created a dashboard for approvers to approve or reject single and multiple requests at a time with the help of the Power Apps Patch function.
In this article, I will explain how to patch a single gallery item in Power Apps and show various examples of how to patch all gallery items in Power Apps.
Power Apps Patch Gallery Selected Item [Single Item Only]
In my leave management application, the employee leave requests undergo two levels of approval. So, I displayed all employee leave requests in the Power Apps gallery control in the dashboard.
When approver 1 selects a pending leave request, he can provide comments and approve or reject it by clicking on the buttons. If he approves, the status will be updated as Approver 2 Pending; if he rejects it, it will be updated as Approver 1 Rejected.
When approver 2 approves the leave request, the status value is updated as Approver 2 Approved. If he rejects it, it will be updated as Approver2 Rejected. Approver2 can also provide comments that will be saved to the SharePoint list. The example below displays the same thing.

Here is the SharePoint list that contains employee leave requests.

| Column Name | Data Type |
|---|---|
| Leave Title | Single line of text |
| Employee Name | Person |
| Leave Type | Choice(Sick ,Maternity, Annual, Compassionate) |
| Start Date | Date & Time |
| End Date | Date & Time |
| Department | Choice(IT,Sales,Marketing,HR) |
| Leave Days | Number |
| Approver Comments | Multiline text |
| Manager Name | Single line of text |
| Status | Choice(Approver1 Pending,Approver1 Approved,Approver1 Rejected,Approver2 Pending,Approver2 Approved,Approver3 Rejected) |
1. In Power Apps, add a gallery control and provide the SharePoint list name below in its Items property.
'Employee Leave Requests'

2. In the gallery, to differentiate the status value of each leave request, add the below code in the Fill property of the status text label. Also, if you’re unaware of getting status value in the gallery, add the below code in its Text property.
Text = ThisItem.Status.Value
Fill = If(
ThisItem.Status.Value = "Approver1 Pending",
RGBA(174, 208, 221, 1),
ThisItem.Status.Value = "Approver1 Rejected",
RGBA(233, 79, 76, 0.83),
ThisItem.Status.Value = "Approver2 Pending",
RGBA(109, 49, 162, 0.68),
ThisItem.Status.Value = "Approver2 Approved",
RGBA(72, 163, 62, 0.9),
ThisItem.Status.Value = "Approver2 Rejected",
RGBA(233, 79, 76, 0.83)
)
Based on status values, the proved color will be applied to the status text label in the gallery.

3. Add a Power Apps form control and provide the codes for its properties given below.
DataSource ='Employee Leave Requests'
Item = Gal_EmpLeaveRequest.Selected
To display the gallery-selected item in the form control, we need to pass the above code in the item property of the form control.
- Gal_EmpLeaveRequest = Gallery name.
- ‘Employee Leave Requests’ = SharePoint list name.
Note: Except for the approver comments data card, all remaining Display Modes of the data cards are as View.

4. Add two button controls for approve and reject. Then, add the codes below to its OnSelect property.
Approve button’s OnSelect property:
If(
Gal_EmpLeaveRequest.Selected.Status.Value = "Approver1 Pending",
Patch(
'Employee Leave Requests',
Gal_EmpLeaveRequest.Selected,
{
Status: {Value: "Approver2 Pending"},
'Approver Comments': DataCardValue18.Text
}
),
Gal_EmpLeaveRequest.Selected.Status.Value = "Approver2 Pending",
Patch(
'Employee Leave Requests',
Gal_EmpLeaveRequest.Selected,
{
Status: {Value: "Approver2 Approved"},
'Approver Comments': DataCardValue18.Text
}
)
)
Here,
- Gal_EmpLeaveRequest = Gallery name.
- ‘Employee Leave Requests’ = SharePoint list name.
- DataCardValue18 = Approver comments data card value name in the form control.
- If the status value is “Approver1 Pending,” it will update as “Approver2 Pending.” Also, comments will updated.
- If the status value is “Approver2 Pending,” it will update as “Approver2 Approved”, comments are also updated.