Sp-dev-fx-webparts: js-advanced-commenting does not send notifications when Ping Users

Created on 16 Apr 2020  路  8Comments  路  Source: pnp/sp-dev-fx-webparts

Category

  • [x] Question
  • [ ] Bug
  • [ ] Enhancement
  • [ ] Sample request

I have used js-advanced-commenting for my SP online, all the functions are fine, but it doesn't have any notifications when Replying to comments or Ping users.
Any idea how can i do this?

help wanted question

All 8 comments

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@sudharsank I believe you wrote this cool sample, would you have any advice on how to get started on implementing what @tranthachthao1995 would like?

@tranthachthao1995 I am working on the email functionality for reply, once it is tested will release the new version of the component and also will post the code.

Thanks @hugoabernier and @sudharsank for feedback

@tranthachthao1995 Please follow the below steps to send an email if an reply is posted.
Following are the modifications that has to be done on 'SPHelper.ts'

  1. Add the below import
    import "@pnp/sp/sputilities";
  2. Modification to be done on the postComment method, below the line
    let updateComments = await this.updateComment(pageurl, comments);
if (commentJson.parent !== null) {
                let allComments = await this.getComment(pageurl);
                allComments = JSON.parse(allComments);
                let parentComment = _.find(allComments, (o) => { return o.id === commentJson.parent; });
                let parentCommentUser = await sp.web.getUserById(parentComment.userid).get();
                let toEmail = [`${parentCommentUser.Email}`];
                let mailsubject = "Reply to your comment!";
                let emailBody = `A reply has been posted by '${commentJson.fullname}'`;
                this.sendEmail(toEmail, mailsubject, emailBody);
            }
  1. Create a new method for sending an email. Paste the below code after the postComment method
public sendEmail = async (to, subject, body) => {
        return await sp.utility.sendEmail({
            To: to,
            Subject: subject,
            Body: body
        });
    }

Thats it. Try the above steps and let me know if you have any clarifications or facing any issues.

Happy coding...

Hi @tranthachthao1995, have you tried the solution mentioned above? Please let us know.

Sorry I missed your guide.
I just apply it and the result is that it works well. Thanks @sudharsank so much.

@tranthachthao1995 I hope it resolves your question. Can you please close this issue?

Was this page helpful?
0 / 5 - 0 ratings