web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Integrating like butto...
Power Apps
Answered

Integrating like button in powerapps in Sharepoint list

(1) ShareShare
ReportReport
Posted on 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

Categories:
I have the same question (0)
  • BCLS776 Profile Picture
    8,994 Moderator on at

    A Sharepoint list is structurally much the same as an Excel table data source, so making the change involves creating the necessary columns and then adjusting the app code to refer to the list rather than Excel. Is there a specific issue you are running into difficulties?

     

    Bryan

  • Community Power Platform Member Profile Picture
    on at

    Thank you for your prompt reply , 

    First step what I did was create two column called LikesID and CreatorEmail and then I made a like *icon* and Onselect property used 

     

    Patch(
    'IT Helpdesk Comments',
    Defaults('IT Helpdesk Comments'),
    {
    LikesID:ThisItem.LikesID,
    CreatorEmail:User().Email
    }
    )

     

    then I would like to enable a the user to click only once and have it disable so on Displaymode of like icon , I get delegation error on CreatorEmail could you kindly help me debug the delegation error on this.

     

    Arsal_0-1630658833859.png

     

     

     

  • BCLS776 Profile Picture
    8,994 Moderator on at

    Firstly, your function should work no matter the delegation limits. The CountRows() function is the non-delegable part, and as long as it counts at least one row then your app logic still applies. It doesn't matter if it counts 1 row or 2000 - your result is the same. If you still need to make it delegable, use With():

    With(
     wFilter: {Filter(
     'IT Helpdesk Comments', 
     CreatorEmail = User().Email, 
     LikesID = Text(ThisItem.LikesID)}
     ),
     If(CountRows(wFilter)>0,
     Displaymode.Disabled,
     DisplayMode.Edit
     )
    )

     

    Also, consider using LookUp() instead of Filter() in this case. LookUp() returns as soon as it finds a matching record, while Filter() goes through the entire table. This might help app performance a bit.

     

    Hope this helps,

    Bryan

  • Community Power Platform Member Profile Picture
    on at

    Unfortunately I tried the Solution provided above but I got the error , 

     

    Arsal_0-1630777924436.png

     

    I thought the problem was with the With statement so I changed the curly bracket but then it error showed up in IF statement and yes I also tried with Lookup but sadly I did not work.

     

    Arsal_0-1630778191419.png

     

    The LikesID is a Number field and CreatorEmail is a Single line of Text . 

     

    I hope this helps and thanks alot for your constant support and help.

     

  • BCLS776 Profile Picture
    8,994 Moderator on at

     

    Arsal_0-1630778191419.png

     

    The LikesID is a Number field and CreatorEmail is a Single line of Text . 

     

    I hope this helps and thanks alot for your constant support and help.

     


    Thanks for catching my free-typed syntax error. Your code quoted above should work and I can get a similar piece of code in one of my test apps to work with your syntax. To troubleshoot, could you do two things?:

    • Make sure this code appears in the DisplayMode property of your Likes icon. I think this is the case, but let's verify it.
    • Can you share the error message getting flagged on the If() statement? I note that the expression "Displaymode.Disabled" has not been changed by the Intellisense feature to "DisplayMode.Disabled", so a re-type of that piece of the code may be all that is necessary to get this working.

    Bryan

  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    @Anonymous ,

    As per the PM you set me - firstly @BCLS776 is correct on the information you provided - your issue is with the field type (as you have now confirmed, LikesID is numeric)

    With(
     {
     wFilter: 
     Filter(
     'IT Helpdesk Comments', 
     CreatorEmail = User().Email &&
     LikesID = ThisItem.LikesID
     )
     },
     If(
     CountRows(wFilter)>0,
     Displaymode.Disabled,
     DisplayMode.Edit
     )
    )

     

  • Community Power Platform Member Profile Picture
    on at

    Thanks alot Bryan and Waren , It worked !

     

    But another problem is I am getting delegation error on this code as well 

     

     

    If(
     CountRows(
     Filter(
     'IT Helpdesk Comments',
     LikesID=ThisItem.LikesID
     )
     )>1,
     CountRows(
     Filter(
     'IT Helpdesk Comments',
     LikesID=ThisItem.LikesID
     )
     )& "people likes this ",
     CountRows(
     Filter(
     'IT Helpdesk Comments',
     LikesID=ThisItem.LikesID
     )
     )=1,
     CountRows(
     Filter(
     'IT Helpdesk Comments',
     LikesID=ThisItem.LikesID
     )
     )& " person likes this ",
     "Be the first to like this "

     

     

    But I seem to be getting delegation error and I tried to make a work around by using the With on to my Filter to avoid it and so far this part of the code works.

     

    With(
     {
     LFilter: 
     Filter(
     'IT Helpdesk Comments', 
     LikesID = ThisItem.LikesID
     )
     },
     If(
     CountRows(LFilter)>1,
     "people likes this "
     )
     
     
    )

     

     

    The code  above works till when I try to add another statement countrows statement where =1 then it gives me the error. 

     

    Arsal_0-1630832140605.png

     

    Thanks once again both of you 

    Arsal 

  • Verified answer
    WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

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

     

  • Community Power Platform Member Profile Picture
    on at

    @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.

  • WarrenBelz Profile Picture
    153,051 Most Valuable Professional on at

    @Anonymous ,
    Amended on initial post

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard