cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Update rating value from gallery in SharePoint

Hi guys,

 

Need your help. I want to rate the following gallery and update the rating value in SharePoint List.

 

I tried to do something like this on the "Rate" Button OnSelect Property:
ForAll(Gallery1.AllItems, UpdateIf('ListName', Status="Approved", {Rating: Rating1.Value}));

 

But it only captures the last rating value of EMS-10020 gallery and update the same value to EMS-10018 and EMS-10019. In another words, it updates EMS-10018, EMS-10019 and EMS-10020 with the same value of EMS-10020's rating value.

 

Just to inform you that, there is one column in my List named "Status" and the status of all items in the gallery below are "Approved".

 

shabilass_0-1594084746506.png

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to update the items that status is approved by using the ratings in the gallery?

Firstly, let me explain why you met the problem:

The key point is that UpdateIf function is used to update all the items that meet the condition.

So in your original formula, actually you update all the items that status is approved for multiple times.

The first time, update all the items that status is approved with the first rating value.

The second time, update all the items that status is approved with the second rating value.

....

The last time, update all the items that status is approved with the last rating value.

So in the end, all the rating fields look like being updated by the last rating value.

 

To solve this problem is to add a condition in the updateif function to make sure each item only be updated to its related rating.

Since ID is the unique field in sharepoint, so I suggest you use ID field as the second condition.

What's more, since ID field exists both in gallery.allitems and the sharepoint list, so you need to firstly save the gallery.allitems as collection, then use [@] to avoid ambiguity when comparing ID field.

Try this formula to update:

ClearCollect(collection1,Gallery1.AllItems);
ForAll(collection1, UpdateIf('ListName', Status="Approved"&&ID=collection1[@ID], {Rating: Rating1.Value}));

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to update the items that status is approved by using the ratings in the gallery?

Firstly, let me explain why you met the problem:

The key point is that UpdateIf function is used to update all the items that meet the condition.

So in your original formula, actually you update all the items that status is approved for multiple times.

The first time, update all the items that status is approved with the first rating value.

The second time, update all the items that status is approved with the second rating value.

....

The last time, update all the items that status is approved with the last rating value.

So in the end, all the rating fields look like being updated by the last rating value.

 

To solve this problem is to add a condition in the updateif function to make sure each item only be updated to its related rating.

Since ID is the unique field in sharepoint, so I suggest you use ID field as the second condition.

What's more, since ID field exists both in gallery.allitems and the sharepoint list, so you need to firstly save the gallery.allitems as collection, then use [@] to avoid ambiguity when comparing ID field.

Try this formula to update:

ClearCollect(collection1,Gallery1.AllItems);
ForAll(collection1, UpdateIf('ListName', Status="Approved"&&ID=collection1[@ID], {Rating: Rating1.Value}));

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

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 (5,259)