Skip to main content

Comments

Enables users to communicate via a message board on an entity. This can be used, for example, for multiple users to post messages.

The Comments are established on an entity that will represent the individual comments:

Text Attribute – Represents the content of the comments
Datetime Attribute – Non-nullable attribute to represent the time of creation
User Attribute – Represents the user who made the comment
Direct Reference – There must be a direct reference to a Parent entity

The Comment component is added to the view. The following information is required:

Item Entity – The entity that represents individual comments
Title – The title of the comment component
Text Attribute – The attribute that represents the content of a comment
Creator Attribute – The attribute that represents the creator of a comment
Created Attribute – The attribute that represents the time that a comment is created
Parent Entity Reference – The entity that receives the comment functionality
Visible Expression – Security condition to show the comment component
Enabled Expression – Security condition that needs to be “true” to allow users to create comments
Pending Attribute – Optional bool attribute marking a comment whose text is still being produced (see below)
Height – Optional fixed height of the comments and the message input together, in CSS units (e.g. 400px, 30rem, 60vh). The comments scroll inside it, and a longer message takes its room from the list. Empty lets them grow with their content up to half of the window
Composer position – Top (default) shows the message input above the comments, newest first. Bottom shows it below them, newest last, like a chat

Behavior​

  • Comments are listed newest first, or newest last with the composer at the bottom. Older ones load as the list is scrolled towards them, and sending a comment scrolls the list back to it.
  • The text is rendered as Markdown, and a single new line is kept as a line break. HTML in it is sanitized, so scripts and event handlers never run.
  • Your own comments are shown on the right; comments of other users show their name and avatar.
  • A new comment is sent with the Send button or with Enter; Shift+Enter starts a new line. On a phone or tablet Enter starts a new line and the Send button sends. The toolbar (Aa) adds Markdown formatting, an emoji picker and a preview. It is created through the item entity's create command, so entity events and audit apply to it as to any other new record.
  • Only signed-in users see the comments.

Pending comments​

When a comment is written by something that takes a while – an AI assistant answering a question, for example – create it first with the Pending attribute set to true and an empty or partial text, and set the attribute to false once the text is complete. While a comment is pending, it is shown with a typing indicator, and the component re-reads the comments (after 1 s, 2 s and then every 5 s, for at most 5 minutes) so the finished text appears without reloading the page.

The pending comment has to be saved before the slow work starts, otherwise nobody sees it: typically an inline business event on the user's comment creates the pending answer, and a queued command fills it in.

To see how the Comments component is establish, go to the following tutorial. It is based on the Support Ticket Base.

Examples​