Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ZHcQds55GYoL5MmUK4UNB1
Power Apps - Building Power Apps
Answered

Integrating like button in powerapps in Sharepoint list

Like (1) ShareShare
ReportReport
Posted on 2 Sep 2021 16:09:06 by

I would like to have a *like* button for users on a gallery which is comment , where people can come and press a like on the comment or remove the like but It should be only enabled once per users . once the user hover over the counter for the likes then then people who have like the comment should be seen in another gallery. 

 

I found a related video to this thing but unfortunately the data was called from Excel sheet and I would like to have it from a Sharepointlist for which the method is different.

 

(15) HOW TO: Add 'Like' Functionality To PowerApps - YouTube

  • Community Power Platform Member Profile Picture
    on 06 Sep 2021 at 07:25:01
    Re: Integrating like button in powerapps in Sharepoint list

    Alright Bryan thanks for clearing it out to me and I will create a new post and adresse this problem there sorry I am new to this so yea 🙂 

  • BCLS776 Profile Picture
    8,988 Super User 2025 Season 1 on 06 Sep 2021 at 00:35:30
    Re: Integrating like button in powerapps in Sharepoint list

    @Anonymous wrote:

    @WarrenBelz @I understand thank you for your help so far, Its kind of you to take an extra step to help me out😁@BCLS776  Do you think the problem lies with the patching of Post comment or Likes icon? For reference scroll to the previous posts here. 


    @Anonymous as Warren points out, this thread deviated a long way from the initial question, which makes it confusing not only for me to respond, but even more confusing for other users who want to learn from this thread. Could you finish this one off by selecting a solution to your original query and then starting a new post with a specific question?

    The one thing I am wondering as I review this thread - it looks like you are trying to store comments and count "likes" on those comments, but that you are also trying to store data about specific likes on the same list? If I've got that right, there is an underlying data structure issue that will cause more problems for you - you are trying to store two different schema in the same list. Or, I misunderstand the situation. Perhaps your next post should address whether you've got the data structured correctly?

    Regards,

    Bryan

  • Community Power Platform Member Profile Picture
    on 06 Sep 2021 at 00:10:16
    Re: Integrating like button in powerapps in Sharepoint list

    @WarrenBelz @I understand thank you for your help so far, Its kind of you to take an extra step to help me out😁@BCLS776  Do you think the problem lies with the patching of Post comment or Likes icon? For reference scroll to the previous posts here. 

  • WarrenBelz Profile Picture
    146,792 Most Valuable Professional on 05 Sep 2021 at 23:57:04
    Re: Integrating like button in powerapps in Sharepoint list

    @Anonymous ,

    This is getting beyond you post subject (which I only came in on as a result of the PM you sent me). Before we go any further, is your initial query solved?

    I am sorry, but I do not have the time in the next few days to debug your second query - as @BCLS776 responded to your post, I will have to leave it with Bryan.

  • Community Power Platform Member Profile Picture
    on 05 Sep 2021 at 23:23:13
    Re: Integrating like button in powerapps in Sharepoint list

    Hi sorry I have explained it in a very bad way so basically I wanted the number of likes to be shown as per the users who pressed the liked button but it seems that functionality is working with the post comments as it is showing total number of comments that the users who posted the comment rather than likes .  

     

    Below is the code for Gallery where the numbers of likes and comments are being displayed

     

    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
     )
     )
    )
    
  • WarrenBelz Profile Picture
    146,792 Most Valuable Professional on 05 Sep 2021 at 21:33:10
    Re: Integrating like button in powerapps in Sharepoint list

    @Anonymous ,

    Sorry I am a little lost as to what your issue is - the code you have posted (please do it all in Text) seems correct. Wat is not working and what code is involved?

  • Community Power Platform Member Profile Picture
    on 05 Sep 2021 at 12:26:02
    Re: Integrating like button in powerapps in Sharepoint list

    Thanks alot for the amendment it helped , Alright so more weird problem that I am facing now, So far the functionality is working but not on the like button but instead its detecting the number of counts from the Comments section . 

    Arsal_1-1630844128169.png

     

    So when I post a comment the counter increases for the people who likes this label . 

     

    and the post comment Onselect code is here below that I patched . 

     

     

    Patch(
     'IT Helpdesk Comments',
     {
     CommentsID: Gallery_ActiveTickets_1.Selected.ID,
     Comments: RichTextEditor1.HtmlText & User().FullName & " - " & Now()
     }
    );
    ResetForm(Form2);
    Reset(Gallery3);

     

    and for the like button the Onselect property is below.

     

    Arsal_2-1630844293748.png

     

    Do you think the problem is connected to gallery because in the same gallery I am trying to integrate two different functions ( Comment and like) and they seem to be now inteconnected but in wrong way. Here below is the patching for gallery 

     

    Arsal_3-1630844734052.png

     

  • WarrenBelz Profile Picture
    146,792 Most Valuable Professional on 05 Sep 2021 at 11:26:05
    Re: Integrating like button in powerapps in Sharepoint list

    @Anonymous ,
    Amended on initial post

  • Community Power Platform Member Profile Picture
    on 05 Sep 2021 at 11:14:35
    Re: Integrating like button in powerapps in Sharepoint list

    @WarrenBelz  ,

    I tried and unfortunately the counter  where the number of likes are added does not work ,

     

    Arsal_0-1630840218537.png

     

    It gives me the error report invalid argument. Expecting one of the following: Text,Number,Boolean,optionSetValue,ViewValue.

     

    I dont know if this is important or not but I also added on the on select part the following statement 

     

    Arsal_1-1630840432432.png

     

    So that when I can create the gallery I can show peoples image and make the Showwholiked gallery visible when clicked on to the likes seen.

  • Verified answer
    WarrenBelz Profile Picture
    146,792 Most Valuable Professional on 05 Sep 2021 at 09:14:46
    Re: Integrating like button in powerapps in Sharepoint list

    @Anonymous ,

    You just need to watch your brackets - a hint for you, always indent your code as you write it - you will pick a lot of syntax issues visually

    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 "
     )
    )

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 14

#2
LC-26081402-0 Profile Picture

LC-26081402-0 10

#3
stampcoin Profile Picture

stampcoin 6

Overall leaderboard