List view of comment field in a form view
Asked by Jim Rogers:

Hey all!

I have a Confiforms Form View that is accessed from either a Create or from an Edit Control via the Table View. (Working perfectly).

I have added a Comment field (Comment data type) on the Form definition and Form View. I am displaying the comments in a List view ++within++ the Form View of the individual entry/row. Inputting a new comment works fine and is associated with the individual row.

I have two issues -

1 - List View within the Form View is displaying ++all++ comments across the data set. It needs to filter (display) for the row in context but the syntax seems to be tricky. I assume something like a filter in the List view like \[entry.id\]=\[id\] to get only the comments for the current record. But I can't seem to make it work.   

2 - Also, the sorting by comment.timestamp DESC (to get the most recent comment to the top) only seems to sort by date but not time.

I assume this has already been solved as have comments for a given record, sorted by most recent is a common need. Or if not, others could benefit.

Thanks! Jim


Answers:
author: Alex Medved _ConfiForms_
body: Hi [@Jim Rogers](/t5/user/viewprofilepage/user-id/4980848)

ConfiForms FormView is usually shown when adding new records, and therefore there is nothing to "filter on"

I mean, what comments do you want to show for the new record? It should have none (as record does not exist yet)

Normally the filter by the "current record in the context" would be something like

```
id:[entry.id]
```

Alex

comments: author: Jim Rogers
body: Alex,

Thank you for the response. The primary use case is to Edit entries in the Data Set as we don't add them new very often. So the Form View is primarily for record maintenance including adding "Progress and/or Update" comments. Your above suggestion on using id:\[entry_id\] worked.

Any thoughts on point #2 with sorting? I am sorting in the list view (or table view) in the form with mycommentfield.timestamp DESC or mycommentfield.timestamp ASC and it doesn't have an impact. It makes the most sense to have the most recent comment at the top of the list and everything below in reverse chronological order.


author: Alex Medved _ConfiForms_
body: ConfiForms can sort records within the form as you like, but it cannot sort the values within it's field. As I understand you want to sort the comments within a comment field... not sure why you need that (they are sorted already by the field itself), but it is not possible to override


author: Jim Rogers
body: Alex,

We are now successfully using the comment field type across our projects! Just an enhancement request to make it more useful.

1 - An option to sort in reverse chronological order to show the latest comments first.

2 - An option to limit the number of comments displayed. For example, to show the latest 2 updates to limit the view the latest entries but not the entire comment history.

Thanks,

Jim


author: Alex Medved _ConfiForms_
body: Hi [@Jim Rogers](/t5/user/viewprofilepage/user-id/4980848)

Thank you for your feedback.

Not the best place to collect it ([better to open a support ticket with us](https://wiki.vertuna.com/display/VERTUNA/Support+Request+Form)), but I appreciate it very much.

Alex


author: Alex Medved _ConfiForms_
body: What you can do already now.. and this is a "bit" scary... is to have the following expression

Assuming the "Comment" field is named "commentField"

```
[entry.commentField.sort(timestamp DESC).limit(2).iterateAndPrint([entry.content] <br/>).unescape.renderAsHtml]?
```

Sorting by comment timestamp DESC, and limiting to only 2 comments and then.. iterating through and printing the contents

Alex


author: Sai Daliboina
body: Hi,

I would like to know how to implement the comment field with a sort in reverse chronological order to show the latest comments first ?

Thanks,

Sai


Tags: confiforms

confluence-server

server