Hello Powerapps Community ,
I am trying to store comments and count "likes" on those comments, but apparently I am also trying to store data about the number of total likes from the users for that comment on the same Gallery . There is an underlying data structure issue in the gallery and I require support for it 🙂 .
So far the problem looks like this here below the people like this filter is actually using the numbers from total number of comments rather than total number of likes .

The Sharepoint list looks like this so its clear what field is what .

This is the code for gallery that is in Items property .
With(
{
records:
Filter(
'IT Helpdesk Comments',
CommentsID = Gallery_ActiveTickets_1.Selected.ID
)
},
ForAll(
Sequence(CountRows(records)),
Patch(
Last(
FirstN(
records,
Value
)
),
{rowNumber: Value}
)
)
This is the Onselect property of the post comment where, when a user comments in Richtext editor , it is then being patched to the gallery .
Patch('IT Helpdesk Comments',{CommentsID:Gallery_ActiveTickets_1.Selected.ID,Comments:RichTextEditor1.HtmlText & User().FullName & " - " & Now() }); ResetForm(Form2);Reset(Gallery3);
With(
{records:'IT Helpdesk Comments'},
ForAll(Sequence(CountRows(records)),Patch(Last(FirstN(records, Value)), {rowNumber: Value}))
)
Then comes the part where the Like Icon Onselect property code is being patched
Patch(
'IT Helpdesk Comments',
Defaults('IT Helpdesk Comments'),
{
LikesID:ThisItem.LikesID,
CreatorEmail:User().Email
}
)
Display mode property of the Like icon
With(
{
wFilter:
Filter(
'IT Helpdesk Comments',
CreatorEmail = User().Email &&
LikesID = ThisItem.LikesID
)
},
If(
CountRows(wFilter)>0,
DisplayMode.Disabled,
DisplayMode.Edit
)
)
Text property of the Label where number of likes counter is being shown
With(
{
LFilter:
Filter(
'IT Helpdesk Comments',
LikesID=ThisItem.LikesID
)
},
If(
CountRows(LFilter)>1,
Text(CountRows(LFilter)) & " people likes this ",
CountRows(LFilter)=1,
"One Person likes this ",
"Be the first to like this "
)
)
Then here is the Onselect property of the Label of Number of likes
With(
{
wFilter:
Filter(
'IT Helpdesk Comments',
LikesID = ThisItem.LikesID
)
},
If(
CountRows(wFilter)>0,
Set(
ShowWhoLiked,
true
)
)
)