cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rogierv
Frequent Visitor

Editing complete column of collection

Hello everybody

 

Over the last couple of weeks i have learned a lot from you guys from reading the answers on this forum but i have an issue which i can't solve on my own.

 

I have created an input form and my data is saved into a collection(ProductList2) Now i want to add a button which can edit all the records in one column (column name = "Product") of the entire collection based on the input of a textbox. This is what i came up with but it doenst do the trick

 

ForAll(ProductList2; Patch(ProductList2.Product; {Product : TextInput1.Text }))

 

Can someone help me please

 

Best regards

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @rogierv 

A quick way to update all the records in a collection is to use the UpdateIf function. The syntax would look like this:

 

UpdateIf(ProductList2; 
true;
{Product : TextInput1.Text }
)

View solution in original post

4 REPLIES 4
timl
Super User III
Super User III

Hi @rogierv 

A quick way to update all the records in a collection is to use the UpdateIf function. The syntax would look like this:

 

UpdateIf(ProductList2; 
true;
{Product : TextInput1.Text }
)

View solution in original post

rogierv
Frequent Visitor

Timl

 

Thank you for this solution. How simple can it be. You helped me a lot

rogierv
Frequent Visitor

Timl

 

Would you advise to always use Updat and UpdatIf when you use a collection? Because I used PATCH before. When i would use Update and want to change one cell in a row with the patch function that would be

 

Patch(ProductList2;Gallery3.Selected; {Product : TextInput1.Text })

But with the UPDATE function this is not gonna work

timl
Super User III
Super User III

Hi @rogierv 

In general, we would use Patch to modify or add a single record to a datasource/collection, and UpdateIf to update multiple records.

The Update function works a bit differently to Patch because it replaces a record in a data source with the record you specify, whereas Patch modifies the target record.

When updating a single record, one thing to be aware of is that Patch doesn't handle null values very well. In these circumstances, the UpdateIf function can provide a workaround.

https://powerusers.microsoft.com/t5/General-Discussion/Patch-not-updating-on-null-values-in-database...

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (39,470)