Patch collection in Powerapps

579 Views Asked by At

I tried to patch my collection but instead it creates like another record as seen in the picture...

enter image description here

I used this formula:

Patch(
    colSubtract,
    Defaults(colSubtract),
    {CurrentBalance: varSub}
);

Then I tried to use the Lookup function but that didn't work at all...

Patch(
    colSubtract,
    LookUp(colUpdates, ID=First(colSubtract).ID),
    {CurrentBalance: varSub}
);

What am I missing?

P.S: I would also like to patch varSub back to my sharepoint list...

1

There are 1 best solutions below

0
mmikesy90 On

The second argument of Patch() is the record (or row if you like) you want to update in your data source.

  1. Using Defaults() is always creating a new record.
  2. Your LookUp() is returning a record from another collection (colUpdates). That is not something you can update in colSubtract.

You could use LookUp(colSubtract,...) to identify your record. Alternatively, if it is always the first one, simply use formula like this:

Patch(colSubtract,First(colSubtract),{ <your updates> })