context_v1_pointsAutomation.AwardPoints assigns points twice

Hi, I have developed a custom points automation for assigning points to a reply author when someone likes the reply (Event: ForumReplyVote.AfterCreate).

It works well if a user clicks the vote up/down button, but when the thread author makes the reply as a "verified answer," the system automatically fires a "Vote" event and assigns the points twice.

In the logs, below statement being called only once, but i see two entries in pointtransaction table in the database.

context_v1_pointsAutomation.RevokePoints(userId, context_v2_automationTrigger.Arguments.ContentId, context_v2_automationTrigger.Arguments.ContentTypeId);

logs:

25 Oct 2021 12:57 PM2 TimesIP 10.208.190.46
Assign points to content author- Ended

25 Oct 2021 12:57 PM2 TimesIP 10.208.190.46
Assign Points

25 Oct 2021 12:57 PM2 TimesIP 10.208.190.46
awardedPoints:: false

ContentFragmentRenderingError
25 Oct 2021 12:57 PM2 TimesIP 10.208.190.46
Assign points to content author -started

Any help on this will be greatly appreciated.

Thank you!!

  • Former Member
    0 Former Member

    If you are aiming for it to only be assigned once per user per thread, use context_v1_pointsAutomation.ArePointsAwarded to confirm whether points already exist for that user and thread.

    I'm not sure how that code snippet is related since that would be revoking points. I also don't know where your event log messages are firing from.

    I see a ContentFragmentRenderingError. Does looking this error up in the exceptions log provide any additional details?

  • Hi Steven, Thank you for the response. I dont see any exception in the logs.

    Below is the code snippet. It fires on - ForumReplyVote.AfterCreate event

    var userId = context_v2_automationTrigger.Arguments.UserId;
    core_v2_exceptions.Log("Assign points to content author -started");
    var forumReplyResponse = core_v2_forumReply.Get(context_v2_automationTrigger.Arguments.ReplyId);
    var awardedPoints = context_v1_pointsAutomation.ArePointsAwarded(forumReplyResponse.Author.Id, forumReplyResponse.contentId, core_v2_forumReply.ContentTypeId);
    core_v2_exceptions.Log("awardedPoints"??+ awardedPoints);
    if (!awardedPoints) {
    context_v1_pointsAutomation.AwardPoints(forumReplyResponse.Author.Id, forumReplyResponse.contentId, core_v2_forumReply.ContentTypeId);
    }
    core_v2_exceptions.Log("Assign points to content author- Ended");

    I brought this code to my Vanilla version of the community and tried. Again, I see the same issue. After the "verify answer" action, the system fires my custom achievement once, but awards point twice.

    Thanks you!

  • Former Member
    0 Former Member in reply to cdns

    I was able to run the above code successfully and only have points assigned once. A development note - you might want to use core_v2_eventLog instead of core_v2_exceptions, it might make it easier to track since duplicate exceptions get rolled up.

    Where are you verifying where points are assigned? Can you share a screenshot?

    I'm assuming you've created a configured points rule using this automation, otherwise it wouldn't be running at all. Can you confirm you only have one configured enabled points rule using this automation?

  • Is the 2nd point award, coming from another point automation, perhaps one for having an answer verified? 

  • I checked again, only these are the active point automations:

    • Verify answer -  30 points
    • Reply to a post - 15 points
    • Vote on a post reply - assign it to reply author - 7 Points
    • New post - 5 Points

    Here are the steps:

    1)  User1 starts a Q & A thread

    2) User 2 responds to the question

               -- Gets 15 points

    3) User 1 makes the reply as a "verified answer"

    4) User 2 gets

                30 for Verified answer

                 7 for user1 voting on the reply

                 7 for user1 voting on the reply (Repeat)

                   

  • Do you have two different items that are both using the same Automation when you look at the Membership > Points page in administration.  I can repro this by adding two different usages that both use your automation above.  First time, you vote on a reply, get two different point awards.  Change vote and awardedPoints is true and no new points records are added.  You should also be seeing 2 instances of each exception getting added the first time you vote on a reply.

  • Former Member
    +1 Former Member in reply to cdns

    Thank you for the additional info and repro steps. I'm able to reproduce this now, and have logged a bug. To workaround, you can edit the Forum - Thread widget ui.js file to make sequential calls in the voteReply function, instead of simultaneous.

    		voteReply: function (context, replyId) {
    			// up-vote the quality of the reply along with voting up the answer/verification
    			return $.telligent.evolution.post({
    				url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/forums/threads/replies/{ReplyId}/vote.json',
    				data: {
    					ReplyId: replyId,
    					VoteType: 'Quality',
    					Value: true
    				}
    			}).then(function(){ 
    			    $.telligent.evolution.post({
        				url: $.telligent.evolution.site.getBaseUrl() + 'api.ashx/v2/forums/threads/replies/{ReplyId}/vote.json',
        				data: {
        					ReplyId: replyId
        				}
        			})
    			});
    		},

    TE-17185: ForumReplyVote.AfterCreate Automation fires twice when Verifying Answer

    Completed for 11.1.12

  • Verint | Telligent Community
    0 Verint | Telligent Community
    TE-17185: ForumReplyVote.AfterCreate Automation fires twice when Verifying Answer has been completed for 11.1.12