Hello,
I've been stuck on this for a while so I hope this forum can help me! I have a powerapp that collects list items from a sharepoint list into the collection cases and display them in a gallery (it does other things too, but this is the part i'm stuck on). I'll explain briefly how I got here in case there is another obvious solution earlier on i'm not seeing.
The problem originally was that clearcollect collected all the list items, but the items have strict permissions on them which gave all our test users "no access" error messages (because they didn't have access to all of the collected list items). I solved this by changing the collection to:
ClearCollect(Cases;Filter(Events; Status.Value<>"Closed" && Responsible.DisplayName = User().FullName));;
Collect(Cases;Filter(Events; Status.Value<>"Closed" && Worker.DisplayName = User().FullName));;
Collect(Cases;Filter(Events; Status.Value<>"Closed" && Author.DisplayName = User().FullName));;
As having your user in the person-fields Author, Responsible or Worker is what gives permission to the list items (though Flow) this solved the permissions problem (a list item is only collected if the current user is in one of these three fields, which means they have permission to all collected items).
However this caused duplicates whenever a user is in more than one field at the time. I looked at the Distinct function, but this would as far as I can tell limit my collection to one table which I don't want. I looked at grouping duplicates together and then degrouping taking only the first of the groups to the new collection but I couldn't get that code to work. I ended up with:
ClearCollect(Cases;Filter(Events; And(Status.Value<>"Closed"; Or(Responsible.DisplayName = User().FullName; Worker.DisplayName = User().FullName;Author.DisplayName = User().FullName)))
However this doesn't give me any results at all.
So my question:
How can I solve this problem? Either by removing duplicates from my collection or getting or-filtering to work in my clearcollect?
Thank you for your time,
Vegard