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

Loop with patch function in OnCheck/OnUncheck

Hello all,

 

I have checked others posts with similar problem but I have not found my answer. I already tried both CDS and a collection has my source data and the error persisted on both scenarios.

 

I am trying to display and save changes based on the toggles. My example is quite simple but I am struggling not to loop the dataflow of my dataset.

My source data is the following:

ClearCollect(
MealsCollection,
{
UserID: "1",
UserName: "John",
Meal1: 1,
Meal2: 1,
Meal3: 0
},
{
UserID: "2",
UserName: "Terry",
Meal1: 0,
Meal2: 1,
Meal3: 1
}
)

 

 

 

I have created a gallery with a toggle to display and change the meal value (which is a true or false value). I want to patch the value whenever the value is changed but then the apps goes on loop.


On each the toggle I definied the following (as example l'll describe the first one):

Defaults: ThisItem.Meal1

Oncheck: Patch(
MealsCollection,
First(
Filter(
MealsCollection,
userID= ThisItem.userID
)
),
{Meal1:1})

 

OnUncheck: Patch(
MealsCollection,
First(
Filter(
MealsCollection,
userID= ThisItem.userID
)
),
{Meal1:0})

 

When I start to change the value the system just goes in a loop and keep changing the records.

 

Thank you in advance.

Regards,

Pedro Pereira

 

1 ACCEPTED SOLUTION

Accepted Solutions
Frequent Visitor

Re: Loop with patch function in OnCheck/OnUncheck

Now I am not having a problem using the collection. I will use the collection has my source data and then the concurrent function to patch the value changes for both the collection and the CDS.

View solution in original post

1 REPLY 1
Frequent Visitor

Re: Loop with patch function in OnCheck/OnUncheck

Now I am not having a problem using the collection. I will use the collection has my source data and then the concurrent function to patch the value changes for both the collection and the CDS.

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

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

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,415)