cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ckserra33
Helper V
Helper V

Patching 2 data sources with collection

Hi everyone.  I am trying to use a patch function to patch 2 different data sources.  The first patch works great and is easy since it is creating new records with the code.  The second patch needs to update an existing record in a data source.

 

This is the code I am trying to use, but it only updates 1 record, not all records in the collection. I always struggle with bulk patches like this and I am not confident I am using the lookup function correctly.  GameID is a unique field.

 

ForAll(
colDocketGroup,
Patch(
Game_view_powerapps_No_ICRs,LookUp(colDocketGroup,cr3db_gameid = GameID),
{PMTCompleted:PMTTiming.Text}))

 

Thanks for the help!

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
LaurensM
Resident Rockstar
Resident Rockstar

@ckserra33 could you add the following adjustments as well:

ForAll(
colDocketGroup As Loop,
Patch(
Game_view_powerapps_No_ICRs,
LookUp(Game_view_powerapps_No_ICRs,cr3db_gameid = Loop.GameID),
{PMTCompleted:PMTTiming.Text}))

If this does not work, It might also be worth checking if cr3db_gameid is the correct field name in your Game_view_powerapps_No_ICRs table.

View solution in original post

4 REPLIES 4
LaurensM
Resident Rockstar
Resident Rockstar

@ckserra33 could you try the code adjustment below:

 

ForAll(
colDocketGroup,
Patch(
Game_view_powerapps_No_ICRs,
LookUp(Game_view_powerapps_No_ICRs,cr3db_gameid = ThisRecord.GameID),
{PMTCompleted:PMTTiming.Text}))

 

Explanation:
(1) Your LookUp within the Patch should be the same data source as the one you are patching to in this case. 
(2) When you want to refer to a field within the loop data source (your collection), prefix the field with ThisRecord.

ckserra33
Helper V
Helper V

Hi @LaurensM , thank you for the quick response.  So when I use the code above, it runs without error, but it does not update the data source (Game_view_powerapps_No_ICRs).  I have tried it as GameID = ThisRecord.GameID and I have tried it as "cr3db_gameid" = ThisRecord.GameID with the same results.  Any idea what I am doing incorrectly?

Thankyou

Chris

LaurensM
Resident Rockstar
Resident Rockstar

@ckserra33 could you add the following adjustments as well:

ForAll(
colDocketGroup As Loop,
Patch(
Game_view_powerapps_No_ICRs,
LookUp(Game_view_powerapps_No_ICRs,cr3db_gameid = Loop.GameID),
{PMTCompleted:PMTTiming.Text}))

If this does not work, It might also be worth checking if cr3db_gameid is the correct field name in your Game_view_powerapps_No_ICRs table.

@LaurensM THat worked, thank you very much for your help!

Chris

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,535)