cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ojack21
Level: Powered On

Patch is not patching all selected items

hi everyone,

 

any help you can extend to me will be great! 🙂
I have this little project where I need to patch all selected items, but somehow, I only works for the 1st record even though I selected several items.

 

I followed the video by @Shanescows https://www.youtube.com/watch?v=0xZ4fMJbLvk&t=1387s and yet, I got no success. the difference is that I want to filter out my collection before using it in the ForAll function. Thank you in advance, below are the scripts I have so far.

I have a button to create the Collection:

ClearCollect(
    DataCollection,
    AddColumns(
        Approval_Workflow_Invoice,
        "IsChosen", false,
        "WhoIsApprover", "fname.sname@mail.com" //Office365Users.MyProfileV2().mail
    )
)

 

 

and in my 'Patch Selected' button:

 

ForAll(RenameColumns(Filter(DataCollection, IsChosen), "Approver11", "IamApprover"), Patch(Approval_Workflow_Invoice, LookUp(Approval_Workflow_Invoice, Approver1 = IamApprover),
    {DelegateApprover1: DelegateDropdown.SelectedText.Value}
)
);
ClearCollect(
    DataCollection,
    AddColumns(
        Approval_Workflow_Invoice,
        "IsChosen", false,
        "WhoIsApprover", "fname.sname@mail.com" //Office365Users.MyProfileV2().mail
    )
)
1 ACCEPTED SOLUTION

Accepted Solutions
ojack21
Level: Powered On

Re: Patch is not patching all selected items

thanks @PowerAddict for taking the time to help me on this. I finally made this worked, I should have just stick with the video  of @Shanescows from the start. I thought I have to replace the lookup item to something else instead of using ID = EID, when I finally tried using that, it worked like a charm! 🙂

the solution is this video by @Shanescows 
Select multiple records in a gallery and Patch with the PowerApps ForAll function  

View solution in original post

6 REPLIES 6
PowerAddict
Level 10

Re: Patch is not patching all selected items

Hi @ojack21

Try the ForAll inside Patch with something like this:

Patch(WIPTracking, Filter(Gallery1.AllItems, Status = "Ongoing -Interrupted" || Status = "Ongoing - W/O Interruption"), ForAll(Filter(Gallery1.AllItems, Status = "Ongoing -Interrupted" || Status = "Ongoing - W/O Interruption"), {'Interruption Start': Today(), Status: "Ongoing -Interrupted"}))

WIPTracking is the data source
The filter expression is the list of items I want to patch (you could filter your collection here)
The Filtrr inside the ForAll is the same list of items that you defined in Patch
And lastly, all the updates within the curly brackets: {'Interruption Start': Today(), Status: "Ongoing -Interrupted"

Let me know if you want me to write it up for you using your values.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
ojack21
Level: Powered On

Re: Patch is not patching all selected items

Hi @PowerAddict, thank you for looking at this. yes, if you don't mind, it will be very helpful for me if you can write this based on my sample data, I'm kinda new to this one. 🙂

 

thanks again.

PowerAddict
Level 10

Re: Patch is not patching all selected items

Patch(Approval_Workflow_Invoice, Filter(DataCollection, IsChosen), ForAll(Filter(DataCollection, IsChosen), {DelegateApprover1: DelegateDropdown.SelectedText.Value}))

This formula updates all items from the DataCollection for which IsChosen is true, and updates the Delegate Approver to the approved selected from the dropdown.

This is assuming I understood your use case correctly. I am not sure I understand why you have a lookup: LookUp(Approval_Workflow_Invoice and the need for RenameColumns

If you can please explain in simple English what you are trying to achieve (like how I have done with my formula), I can verify if my formula will work for you.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
Highlighted
ojack21
Level: Powered On

Re: Patch is not patching all selected items

let me explain what I am trying to achieve.

 

I have a sharepoint list, in this list I have records with Assigned Approver (AA) and if the AA is going for a vacation he/she will assign a delegate to work on his/her active tasks, Delegate Approver (DA)

 

Task       AA      DA

task1      a1

task2     a1

task3     a2

task4     a1

task5     a3

 

now I like to have a PowerApps screen where, when AA accesses this screen, he/she will see a list of his/her tasks ONLY (a gallery). S/He can either select individual tasks or all the tasks and by clicking button, the DA will be set to whomever s/he chose from a DA dropdown box, something like below should happen.

 

assign a delegate to work on his/her active tasks, Delegate Approver (DA)

 

Task       AA      DA

task1      a1       a2

task2      a1       a2

task3      a2

task4      a1      a3 

task5      a3

 

hopefully this one is clearer. thanks again @PowerAddict  🙂

PowerAddict
Level 10

Re: Patch is not patching all selected items

Yes. I am going to suggest a design. Let me know if you can put it into practice. If not, I can them give you specific details.

1. I would first create a gallery of tasks filtered on the AA (current signed in user)
2. I would make the gallery editable so individual tasks can be updated.
3. I would also have a dropdown of all DAs that can be picked.
4. If you do make the gallery editable and if there is a scenario that each task could have a diff DA, I would add a dropdown of DAs to each gallery row. So you can let the AA pick DAs in each row and have a save button that patches just that specific record (ThisItem).
5. The dropdown from step 3 can be used if all tasks need to be updated.
6. If you need to update all, the OnSelect of a button should be something like the patch function I shared before:

Patch(Tasks, TasksGallery.AllItems, ForAll(TasksGallery.AllItems, {AA: Dropdown.Selected}))

7. An alternate to step 4 if there is a use case that AA can select individual tasks but have the same DA assigned to them, then you can add a checkbox within the Gallery and collect the ones that are checked. Then use a Patch very similar to the formula in step 6.

Let me know if this helps.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
ojack21
Level: Powered On

Re: Patch is not patching all selected items

thanks @PowerAddict for taking the time to help me on this. I finally made this worked, I should have just stick with the video  of @Shanescows from the start. I thought I have to replace the lookup item to something else instead of using ID = EID, when I finally tried using that, it worked like a charm! 🙂

the solution is this video by @Shanescows 
Select multiple records in a gallery and Patch with the PowerApps ForAll function  

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,999)