cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Update a collection

Hello Friends,

 

I have a collection with name, type and number, I need a way to check if the record with the same number exists in my collection, update it, if not add it to the collection.

 

 
 
 

I did a test but nothing working. 

Any idea? 

 

Thanks in advance. 

6 REPLIES 6
Highlighted
Super User
Super User

Re: Update a collection

@felipewltc
Try this:

If(
!IsBlank(LookUp(your_collection_name, Number=1)),
Collect(your_collection_name, {Name=“Name”, Type=“Type” And Number=1})
)

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
Highlighted
Community Champion
Community Champion

Re: Update a collection

Hi @felipewltc ,

The below is a possible structure you could use - you will need to adapt the names.

If(
   CountRows(
      MyListName,
      NumberYouHave
   )>0,
   UpdateIf(
      MyListName,
      MyNumberField = NumberYouHave,
      {
         Field1:NewValue1
         Field2:NewValue2
      }
   ),
   Patch(
      MyListName,
      Defaults(MyListName),
      {
         MyNumberField:NumberYouHave
         Field1:NewValue1
         Field2:NewValue2
      }
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Helper II
Helper II

Re: Update a collection

I am new at this, so I did not get it very clear. 

If(
   CountRows(
      MyCollection,
      Name of the collection column
   )>0,
   UpdateIf(
      Collection,
      Column collection= Number text box,
      {
         Field1:NewValue1
         Field2:NewValue2
      }
   ),
   Patch(
      myCollection,
      Defaults(myCollection),
      {
         MyNumberField:NumberYouHave
         Field1:NewValue1
         Field2:NewValue2
      }
   )
)

Something like that? 

Highlighted
Helper II
Helper II

Re: Update a collection

Thank you for your answer, why I should use number 1? 

Highlighted
Super User
Super User

Re: Update a collection

@felipewltc
You should not use number 1: it’s just a placeholder. Instead you should put the number you want to check for within the collection.

—-
Please Accept as Solution if this post answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
Highlighted
Community Champion
Community Champion

Re: Update a collection

Hi @felipewltc ,

You need to understand the Patch and UpdateIf syntax to apply this to your needs.

Both myself and @mdevaney can help you here - once you apply the structure to your fields, table and control names, please tag one of us and we will fix whatever you do not get correct.

 

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (6,325)