Blog post

Reputation Point on Reply on Question in community In Salesforce?

Posted on Oct 07, 2015
by Prabhat Gangwar
in Education
with 1 comments

Requirement: When any community user  Reply on question then increase  Reputation Point  of that Community User how ?

Solution: Using Helper ClassCode: 


Trigger :
 

trigger IncreasePointsOfCommunityUserForReply on Reply (after insert) {

 

   IncreasePointsOfCommunityUserReplyHelper.IncreasePointsOfCommunityUserReplyExecute(trigger.new ,trigger.isafter ,trigger.isinsert);  

 

}
 
 
Helper Class: 
 
 
public class IncreasePointsOfCommunityUserReplyHelper{
    public static void IncreasePointsOfCommunityUserReplyExecute(list<Reply> triggernew, boolean isafter, boolean isinsert){    
        if(isafter)
            IncreasePointsOfCommunityUserReplyMethod(triggernew,isafter,isinsert);
    
    }
        public static void IncreasePointsOfCommunityUserReplyMethod(list<Reply> triggernew, boolean isafter, boolean isinsert){
            set<id>ReplyUserid = new set<id>();  // hold id of communityReplyUser
            list<NetworkMember> updatelistofPoint = new list<NetworkMember>(); // updatelistofPoint of cummunity user
                if(isInsert){
                    for(Reply  answerReply : triggernew){
                            if(answerReply.Body != null ){
                                ReplyUserid.add(answerReply.CreatedById);
                            }
                        }
                }
            for(NetworkMember userpoint : [SELECT MemberId,ReputationPoints FROM NetworkMember where MemberId in : ReplyUserid]){
                    userpoint.ReputationPoints = userpoint.ReputationPoints+2; 
                    updatelistofPoint.add(userpoint);
            }
            if(updatelistofPoint.size()>0){
                update updatelistofPoint;
            }
        }
}
 
 
 
 
 


 


1

Leave your comment

    apurva ram
    on Jan 04, 2019
  1. This blog is amazingly fascinating. I found a lot of useful materials for myself from these posts. I have a few special ways for subscribing blogs. If I like your blog, I may subscribe or I will check back regularly without subscribing it. But if I love your blog, I will definitely subscribe via email without thinking much. (  https://panseva.com/  ) This is because I don’t want to take a risk of missing a single update! I want all the new posts as soon as possible.

Leave your comment