As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
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?
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 fmost 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/#managecomments) :
<a href="http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/" target="_blank" rel="noopener nofollow noreferrer">http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/</a><strong><font color="#0000FF">{id}</font></strong>/comments?alf_ticket=<font color="#0000FF"><strong><ticket></strong></font></code></p> <p><code><span>e.g.: <a href="http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/" target="_blank" rel="noopener nofollow noreferrer">http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/</a><font color="#0000FF"><strong>d2084217-8f87-42dd-a1c6-85b0b0bf86e9</strong></font>/comments?alf_ticket=<strong><font color="#0000FF">TICKET_d3484135e30ef51b70dbe1079620f460a48984d0</font></strong></span></code><code>
<a href="http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/" target="_blank" rel="noopener nofollow noreferrer">http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/</a><strong><font color="#0000FF">{id}</font></strong>/comments?alf_ticket=<font color="#0000FF"><strong><ticket></strong></font>
</code></p> <p><code><span>e.g.: <a href="http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/" target="_blank" rel="noopener nofollow noreferrer">http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/</a><font color="#0000FF"><strong>d2084217-8f87-42dd-a1c6-85b0b0bf86e9</strong></font>/comments?alf_ticket=<strong><font color="#0000FF">TICKET_d3484135e30ef51b70dbe1079620f460a48984d0</font></strong></span>
</code><code>
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.