function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Tanisha LaddhaTanisha Laddha 

How to get user record of likes from Feeditem using ConnectAPIs ?

I want to retrieve User Records from Likes on FeedItem using ChatterAPIs.
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Tanisha

Use the FeedLike object using the feedItemId.
Check out this link for documentation:

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_feedlike.htm

Cheers!!!
Raj VakatiRaj Vakati
Here is the code
 
id yourFeedCommentId = [select id from FeedComment limit 1].id;
id yourCommunityId = [select id from Network where Status = 'Live' limit 1].Id;

ConnectApi.ChatterLikePage clp = ConnectApi.ChatterFeeds.getLikesForComment(yourCommunityId, yourFeedCommentId);

integer likeCount = clp.total;

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_like_feed_element.htm