Operator . (dot)
Accesses one or many values from a data table row using the column’s identifier
Usage
Parameters
| data_table_row |
(Required) The data table row to extract a value from |
| column_name |
(Required) The identifier of the column you want to extract the value. Do not put quotes around this. |
| **code** |
(Required) This code is executed with a quick access to every column of the row by using its identifier
prefixed with a dot ( |
Examples
More information
To obtain a data table row:
- Use
DT_CHOICESwith@PICK_ONE_QUESTIONor@PICK_MANY_QUESTION - Use
DT_LOOKUP
DT_CHOICES
Here is an example of a DT_CHOICES and @PICK_ONE_QUESTION:
<# @PICK_ONE_QUESTION(assignee,
label: "Assignee",
choices: DT_CHOICES("employees", CONCAT(.first_name, " ", .last_name))) #>
If you have questions, contact: <# UPPER(assignee.first_name) #> at <# assignee.email #>.
This will provide choices based on the data table employees. The choices displayed in the form
will be the “first_name last_name”, such as “Anna Logwatch”. This requires the data table to have
columns with the identifiers first_name and last_name.
When generating, the value of the variable assignee (set by the @PICK_ONE_QUESTION above)
will be the whole row of the data table. The dot (.) is then used to access the right columns.
For the choice “Anna Logwatch”, here is the result:
If you have questions, contact: Anna at [email protected] #>.
Use many values
Using a parenthesis right after the dot (.) provides a quick way to access to multiple values from the row.
This is especially useful with DT_LOOKUP, since otherwise, the DT_LOOKUP usage would have to be repeated
for each required value, but also works when a row is set in a variable using DT_CHOICES. Here is a comparison for DT_LOOKUP:
Contact Anna at <# DT_LOOKUP("employees", "first_name", "Anna").email #> or at <# DT_LOOKUP("employees", "first_name", "Anna").phone_number #>.
Can be replaced with (remember to close the parenthesis):
Contact Anna at <# DT_LOOKUP("employees", "first_name", "Anna").(CONCAT(.email, " or at ", .phone_number)) #>.
As you can see, values from the row’s columns are accessed using the column’s identifier prefixed with a dot (.).
Both examples would result in:
Contact Anna at [email protected] or at 1-800-555-5542.
You can also use regular variables as in any function, without the dot:
<# DT_LOOKUP("employees", "first_name", "Anna").(CONCAT(.email, IF(show_phone_number, CONCAT(" or at ", .phone_number))) #>.