cancel
Showing results for 
Search instead for 
Did you mean: 

Retreive user comments

cunhasergio
Champ in-the-making
Champ in-the-making

Hello everyone,

Is there any way to perform a query or something similar to identify all the files that have user comments, and if possible, display the comments?

Is there a property to be able to obtain them using JavaScript?

1 REPLY 1

abhinavmishra14
World-Class Innovator
World-Class Innovator

When a user puts a comment on any content in Alfresco repository, an ASPECT called "fm: discussable" is applied to the content node. And a child association with name "fm: discussion" and TYPE "fm: forum" is created that holds the node containing the comments. This  "fm: forum"  node holds another child association with name "cm:comments" and TYPE "fm: topic". Further fm: topic node has a child association with name "cm:comment" and TYPE "fm: post". This fmSmiley Tongueost is the real comment. 

You can build a search query around these pointers to extract the comments for the content node. 

Or if you are planning to use REST API, this is available out of the box (see docs here https://docs.alfresco.com/content-services/latest/develop/rest-api-guide/folders-files/#managecommen...) : 

http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/{id}/comments?alf_ticket=<ticket>

e.g.: http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/d2084217-8f87-42dd-a1c6-85b0b0bf86e9/comments?alf_ticket=TICKET_d3484135e30ef51b70dbe1079620f460a48984d0

This gives you a response like: 

{
                "entry": {
                    "createdAt": "2024-07-31T16:15:44.155+0000",
                    "createdBy": {
                        "enabled": true,
                        "firstName": "John",
                        "lastName": "Doe",
                        "displayName": "John Doe",
                        "email": "jdoe@xyz.com",
                        "emailNotificationsEnabled": true,
                        "company": {
                            "organization": "XYZ"
                        },
                        "id": "jdoe"
                    },
                    "edited": false,
                    "modifiedAt": "2024-07-31T16:15:44.155+0000",
                    "canEdit": false,
                    "modifiedBy": {
                        "enabled": true,
                        "firstName": "John",
                        "lastName": "Doe",
                        "displayName": "John Doe",
                        "email": "jdoe@xyz.com",
                        "emailNotificationsEnabled": true,
                        "company": {
                            "organization": "XYZ"
                        },
                        "id": "jdoe"
                    },
                    "canDelete": false,
                    "id": "3c2b474d-041c-42d1-93df-7cc6c3afd798",
                    "content": "<p>This is a test comment</p>"
                }
            }

You can take out all the comments from the response pertaining to the nodeId passed in the request. 

~Abhinav
(ACSCE, AWS SAA, Azure Admin)