cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
usaman45
Helper I
Helper I

Update collection from other collection

Hi,

I have below two collections:

ClearCollect(CustomerInfo,Table({DisplayName:"John",Email:"John@test.com"},{DisplayName:"David",Email:"david@test.com"}));
ClearCollect(UpdateCustomerInfo,{DisplayName:"John Smith",Email:"John@test.com"});

 

The main collection is CustomerInfo.  I'd like to update CustomerInfo collection using UpdateCustomerInfo collection.  The key is Email value.

 

What is best way to do it?

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@usaman45 

Give the following a try:

ForAll(UpdateCustomerInfo as updates,
    UpdateIf(CustomerInfo, Email=updates.Email,
        {
           DisplayName: updates.DisplayName
        }
    )
)

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@usaman45 

Give the following a try:

ForAll(UpdateCustomerInfo as updates,
    UpdateIf(CustomerInfo, Email=updates.Email,
        {
           DisplayName: updates.DisplayName
        }
    )
)

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

I got this error, any idea?

Incompatible type. The 'DisplayName' column in the data source you're updating expects a 'Text' type and you're using a 'Table' type.
The function 'UpdateIf' has some invalid arguments.

RandyHayes
Super User III
Super User III

@usaman45 

Other than a typo (as should be As), this formula works perfectly on the data you provided.  Are you trying to put this into some other data other than what you provided?  If so, then you will need to adjust for the column types you might have.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Thanks for the help.

RandyHayes
Super User III
Super User III

@usaman45 

Did it work?  Where did you get with it?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (55,003)