Comments
Create, update, delete, and query the available Comments in Box.
Table Specific Information
Comments are additional information passed on to a File. These Comments can also have child Comments.
Select
To query the Comments table specify an Id or a FileId.
SELECT * FROM Comments WHERE Id = '123'
If you're authenticated as an administrator with user impersonation permissions, you can query comments from multiple user accounts:
SELECT * FROM Comments WHERE AsUserId IN (SELECT Id FROM Users)
Note: User impersonation has the following limitations:
- The authenticated user cannot be impersonated unless that user is a service account.
- If the authenticated user is a standard user account, they can only query comments associated with their account.
- Comments shared with multiple users are only returned for one of the users.
Insert
To insert into Comments you need to specify the item to insert the Comment into and the Message. You need to either specify a Message or a TaggedMessage but not both.
INSERT INTO Comments (ItemId, ItemType, Message) VALUES ('1', 'file', 'example comment')
Update
Only the message of the Comment can be updated.
UPDATE Comments SET Message = 'editor' WHERE Id = '100'
Delete
Comments can be deleted by providing an Id and issuing a DELETE statement.
DELETE FROM Comments WHERE Id = '100'
Columns
Name | Type | ReadOnly | Description |
Id [KEY] | String | True |
The Id of the comment. |
Message | String | False |
The plain message of the comment. Use only this or tagged_message not both. |
TaggedMessage | String | False |
The tagged message of the comment. Setting this as @[USER_ID:USERNAME] tags the user and notifies him. A tagged message that does not contain a proper tag will give an error. |
ItemId | String | False |
The Id of the item the comment is targeted to. |
ItemType | String | False |
The type of the item the comment is targeted to. This can be a file or another comment. The allowed values are file, comment. |
CreatedById | String | True |
The id of the user that created the item. |
CreatedByName | String | True |
The name of the user that created the item. |
CreatedByLogin | String | True |
The login user that created the item. |
CreatedAt | Datetime | True |
The date the item was created. |
AsUserId | String | False |
The Id of the user you want to impersonate. Only works with Admin, Co-Admin and Service Accounts. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
Name | Type | Description |
FileID | String |
The File ID the comment is connected to, is not used to insert to this table. |