3

Is it possible to delete a single comment from the comment section at the bottom of the a SharePoint modern page?

Any help with this would be much appreciated!

2 Answers 2

2

We can use REST API to retrieve comments, and manage comments.

To delete a specific comment from a modern page, make a Delete request to:

https://technet.sharepoint.com/sites/<site>/_api/web/lists(<list GUID>')/GetItemById(<page item id>)/Comments(<comment id>)

Reference:

Working with the Page Comments REST API

A script demo of deleting a comment from a modern page:

<script src="https://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script>
ExecuteOrDelayUntilScriptLoaded(DeleteComment, "sp.js");  
function DeleteComment() {  
    var siteURL = _spPageContextInfo.webAbsoluteUrl;  
    console.log("from top nav - " + siteURL);  
    var apiPath = siteURL + "/_api/web/lists('F0D56E41-B532-4F0D-A5B2-000FDE46B86F')/GetItemById(26)/Comments(1)";  
    $.ajax({  
        url: apiPath,  
        type: "DELETE",  
        headers: {  
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val(),
            "If-Match": "*"
        },  
        async: false,  
        success: function(data) {  
            alert("The comment Deleted successfully");  
        },  
        eror: function(data) {  
            console.log("An error occurred. Please try again.");  
        }  
    });  
}  
</script>
2
  • Thank you for your response @JoannaW_MSFT but where do I inject this JavaScript in a modern page? I didn't think custom JavaScript could be added to a modern SharePoint page?
    – L. Full
    Jul 18, 2018 at 14:37
  • You can use the script in the classic page in the same site for running the script. It will work. Jul 19, 2018 at 1:09
0

There is a no code way as well. Navigate to the Site Contents / Document Library and select a view that contains document Name. Hover over the document Name until you see the 3 dots and then select Details.

If you scroll down on details then there is is at the bottom. You can view all activity or just comments. And then Delete the ones you wish.

Comments on Comments appear to be removed as well. But at least we can open up Comments to our users and maintain control! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.