cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PincheMaldy
Regular Visitor

Patch is updating multiple rows instead of one

I'm trying to update one value in a List, based on one toggle control value, inside a gallery but the instruction is updating several rows instead of only one, the instruction is:

 

Patch(
   ListToUpdate,
      LookUp(
         ListToUpdate,
            ProcessID = ThisItem.ProcessesID && ListToUpdateID = listToUpdateValue
       ),
        {
            Completed: true,
            EndDate: Today()
       }
); 

 

The ListToUpdateID value is 2 and there are 9 rows associated with ProcessesID (1, 2, 3, 4, 5, 6, 7, 8, 9), the value of ThisItem.ProcessesID is 3 but the instructionis updating the 9 values related to ListToUpdateID

5 REPLIES 5
eka24
Super User III
Super User III

Watch this tutorial on Patch from Gallery:

https://youtu.be/gKWf_XQyIH0

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Rambling-Reece
Frequent Visitor

Do you need the ListToUpdateID = listToUpdateValue condition? If you are simply using the LookUp to filter the List with a unique ID then simplify and take out this second condition. Also, is it possible that these variables are ambiguous? Might be worth being explicit and using ThisRecord. or As as in here: Patch function - Power Apps | Microsoft Docs

Hi, yes I need both conditions because my list is like:

ListToUpdateID     ProcessID     more fields...

1                                1

1                                2

1                                3

1                                4

1                                5

1                                6

1                                7

1                                8

1                                9

2                                1

2                                2

2                                3

2                                4

2                                5

2                                6

2                                7

2                                8

2                                9

3                                1

3                                2

3                                3

3                                4

3                                5

3                                6

3                                7

3                                8

3                                9

 

Hi, it looks like I'm using the instruction correctly but is not working, is not updating just the required value, is updating all of them

v-albai-msft
Community Support
Community Support

Hi @PincheMaldy ,

By default, LookUp function will return the first single record that matches one or more conditions, so do you have any other code like ForAll? If yes, please provide your full code. If no, try to add a new button, and only use Patch inside this button, then check the result.

If above still cannot solve your issue, from your code, seems that you want to update the record that “ListToUpdateID =2 && ProcessID=3”, and I want to make sure below things:

1. Where do you use this Patch code? Inside the gallery beside each record? Or outside the gallery? 

2. What's the relationship of the toggle control?

3. What is the “listToUpdateValue” mean inside your formula? Is this a column name in your list?

4. Your gallery is not connect to the ListToUpdate list, and it has another similar column name called “ProcessesID”(not same as "ProcessID"). Am I right?

v-albai-msft_0-1620111232999.png

 

For better understand your issue, you can also provide some screenshots about your gallery and other configurations.

Best regards,

Allen

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,834)