Email Notification for liked posts in Community sites

Hello,

If someone likes a disciussion post, is there a way to receive an email notification?

Thanks,

May 19th, 2015 9:00pm

Hi,

There seems no direct method to monitor the Like behavior performed by users.

As a workaround, you can create a custom timer job to check the a feed of activity by the current user periodically, then send an email with the specific information from the feed accordingly.

About how to work with custom timer job:

http://www.codeproject.com/Tips/634208/Create-and-Deploy-Custom-Timer-Job-Definition-in-S

How to get the users who the like the specified post using SPSocialFeedManager.GetAllLikers method:

https://msdn.microsoft.com/en-us/library/office/microsoft.office.server.social.spsocialfeedmanager.getalllikers.aspx?f=255&MSPPError=-2147217396

Thanks 

Patrick Liang

Free Windows Admin Tool Kit Click here and download it now
May 20th, 2015 8:42am

Hello,

Try this...

1) Insert JQuery code on the like button click. to create an entry in a custom list "Likes". (use CSOM)

2) Event receiver on the "Likes" list (your custom list) -> send email on the ItemAdded - Event.

May 22nd, 2015 3:05am

But how do you know who liked your post? 
Free Windows Admin Tool Kit Click here and download it now
May 22nd, 2015 5:32pm

Hi,

The return value of the SPSocialFeedManager.GetAllLikers method is The users who the like the specified post as a collection of SPSocialActor objects.

A SPSocialActor object Represents a user, document, site, or tag in social feed and following activities, you can get the user who like this post with it:

https://msdn.microsoft.com/en-us/library/microsoft.office.server.social.spsocialactor_members.aspx?f=255&MSPPError=-2147217396

Thanks 

Patrick Liang

May 24th, 2015 8:49pm

$('.classOfLikeButton').click(fucntion(){
   var ctx = new SP.ClientContext().get_current();
   var web = ctx.get_web();
   var user = web.get_currentUser();
   var list = web.get_lists().getByTitle("LikeList");
   ctx.load(user);
   ctx.load(list);
   ctx.executeQueryAsync(Function.createDelegate(this, this.OnSuccess), Function.createDelegate(this, this.OnFail));
});

function OnSuccess(sender, args) {
    var listCreationInformation = new    SP.ListItemCreationInformation(); //Object for creating Item in the List
    var listItem = list.addItem(listCreationInformation);
    listItem.set_item("Title", user.get_title());
    listItem.update(); //Update the List Item
    ctx.load(listItem);
    ctx.executeQueryAsync(Function.createDelegate(this, this.userAdded), Function.createDelegate(this, this.OnFail));
}

function OnFail(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

funstion userAdded(sender, args) {
  alert("user added");
}

Please note, above code is just adding the user who liked the post to a list "LikedList". This list will have event receiver code to send email SPUtility.SendEmail(...);

Please put extra condition to check if post is liked or unliked as you click the same button for both cases. I am sure there will be a w

Free Windows Admin Tool Kit Click here and download it now
May 30th, 2015 11:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics