Comments Panel Example
Looking for documentation on the legacy Comments Panel component? Please see the Legacy Comments Panel page.
Not sure which version you are looking at? The Legacy version of this component has several properties that the new one does not: "Insert Query 1", "Insert Query 2", "Delete Query", "Unstick Query", and "Download Attachment Query".
There are many ways to set up the Comments Panel component, but the same first few steps exist in all cases to get started. To set up a simple Comments Panel example, here are the basic steps:
-
Add the Comments Panel component to a window.
-
Create or locate a database table to store notes in. You can follow the sample table in the "data" property of the Comments Panel Component.
-
Add a SQL query to the "data" property of the component to fetch the notes. Make sure to sort the records by timestamp so your newest comments are on top.
-
Save your project and test it out!
By default, a certain database structure is expected. If you want to use different tables, the Extension Functions on this component must be modified.
Additional documentation on the Comments Panel component can be found in the Appendix
Example
The following section assumes the default configuration: all Extension Functions on the component are disabled.
The default behavior of the component expects three database tables be present under the same database connection, and each table needs to have certain columns with specific names.
Table:Notes
Column Name |
Description |
Data Type |
id |
An auto-incrementing integer that is the primary key. This maps to the ID field in the dataset. |
Integer |
whoID |
A mapping to the Username field in the dataset |
Integer |
tStamp |
A mapping to the Timestamp field in the dataset |
Date or Datetime |
note |
A mapping to the NoteText field in the dataset |
Varchar |
filename |
A mapping to the AttachmentFilename in the dataset |
Varchar |
sticky |
A mapping to the Sticky field in the dataset |
Boolean or Integer |
attachment |
A column to hold the attachment data. LongBlobs do not exist in MSSQL, so a varbinary type must be used |
LongBlob or Varbinary (depending on database) |
Table: ItemNotes
Column Name |
Description |
Data Type |
accountId |
An automatically generated UUID for the Comment Panel instance. You can use the accountId in a WHERE clause on the data property so that the component only shows notes from a particular Comments Panel in the project. |
Varchar |
noteId |
An integer that maps to the ID column on the Notes table |
Integer |
Tables: Users
Column Name |
Description |
Data Type |
id |
An integer that is inserted into the whoID column on the Notes table |
Integer |
username |
The username of the user that created the note |
Varchar |
This component expects that its dataset is populated with the following columns. The dataset in the Data property is very specific, and expects certain datatypes at precise positions. The order of expected column positions is listed below. Should the order of datatypes in the dataset differ from the order below, the names of the columns must match the column names below. Aliasing can be used to modify the names of the columns in the dataset.
The names do need to be exact, but different names can be used as long as the query that builds the dataset uses aliases. The data type for each column in your notes table must match the table below.
Column Name |
Description |
Data Type |
Expected Column Position |
id |
an integer that should be the primary key for the notes table. Used for deleting and looking up attachments |
integer |
0 |
username |
the user who added the note |
string/varchar |
1 |
timestamp |
when the note was added |
dateTime |
2 |
notetext |
The text of the note itself |
string/varchar |
3 |
attachmentname |
filename for a file attached to the note |
string/varchar |
4 |
issticky |
0 or 1 indicating whether or note the note is "sticky", which means it gets highlighted and put at the top |
boolean or integer |
5 |
The comments panel also has a set of default queries to handle adding, deleting, and unsticking comments. The default queries expect certain database tables and columns to be set up. If your database is set up differently, or your dataset is different than the default, remember to enable the Extension Functions and provide the correct names.
Example
The following query returns note data from the above tables, and displays the data on a Comments Panel component. This query should be placed in a SQL Query binding on the Data property
SELECT notes.id, users.username as whoid, notes.tstamp, notes.note, notes.filename, notes.sticky FROM notes JOIN users ON notes.whoid = users.id ORDER BY notes.tstamp DESC |
|