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
Highlighted
Frequent Visitor

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
Highlighted
Frequent Visitor

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (14,018)