This article will cover the syntax of the ‘comment’ regular script statement.
The comment statement is a way to add metadata to app fields loaded from databases or spreadsheets. The comments can be added to a single field or a comment map can be specified to comment on multiple fields. Note that comments can be viewed in the preview section of the data model viewer.
Statement syntax
Comment [field | fields]
fieldname | *fieldlist
with | using
comment | mapname
Field | Fields | Field or fields specifies whether a single comment is being added or a comment map is being used. |
Fieldname | Fieldlist | If a single field is being commented on, the name of the field is specified. If a comment map is being used, the comment map must contain 2 columns. The first will be the name of the fields and the second will contain the comments. |
With | Using | The with keyword is used to add a comment to a single field. The using keyword is used to specify the name of a comment map. |
Comment | Mapname | If adding a comment to a single field, this is where the comment is specified. If a comment map is used, this is where the comment map name should be inserted. |
Example
This example adds comments using a comment map to each field in the table ‘ITEM_DETAILS’.
ITEM_DETAILS:
LOAD
id,
cost,
"type",
flavour
FROM [lib://Public:DataFiles/ITEM_DETAILS.qvd] (qvd);
COMMENT_MAP:
MAPPING LOAD * INLINE [
a,b
id,This is the key field
cost,This field contains monetary values
type, This is a string field
flavour, This is a string field
];
Comment fields using COMMENT_MAP;
Result
Comments are loaded for each field specified and are visible below other field metadata in the data model viewer.