How do I get the comment count?

Hello!

I'm using the Comment component: Comment | Retool Component Library and I think it works very well. What I'm interested in is a way to get the count per Note key in order to put that into my table.

Is this possible?

Cheers
Max

@benjwit Welcome to the forum - try the following - disregard column type in screenshot....

I am using my comment1 component {{comment1.comments.length}}

@ScottR thank you and thanks for the reply!

I tried that, but then it just shows the number of comments for the selected row on every row:

This is my Comment component configuration:
Screenshot 2022-05-16 at 17.47.03

Are you associating the comment to that record being pulled from the db at the time the comment is made?

Yes, exactly. But it seems comment1.comments are only the comments for the current note key, I would like to access the count for each different note key or every comment and then I could make the calculation myself.

I know what the issue is... it's a custom column
use another column instead to map to the note key

I used {{table2.selectedRow.data.id}}

then run this query (type is Query JSON with SQL) on Row click event for the table....
select count(*) from {{ comment1.comments }} where {{comment1.evaluatedKey}} = {{table2.selectedRow.data.id}}

take that query result and populate the column but still running into the same issue as you noted above..... this will require more digging....

Hi there!

Unfortunately, the comment component only returns the comments for the specific row key that is passed into it, it doesn't allow any kind of programatic access to all of the unique comments stored in the database.

There is no way to do what you want without direct access to the internal Retool DB, which is only possible on self-hosted Retool. I think it would be easier to save the comments in your own database and not use the comment component at all.

@retool_team thanks for the reply, this is what I suspected.

Is there any way to get this on a wishlist/roadmap/pretty pls it would be cool-list?

Have a nice weekend!

Would you mind posting this as a feature request on the community so that other users who are interested can chime in on this? That would be the best way for us to get visibility on features that people want!