A Logi "token" is a place-holder variable that represents a value and is resolved at runtime. They're essential for creating dynamic visualizations and reports.
The following topics discuss tokens:
- "Nesting" Tokens
- Token Types
- @Function Tokens
- @Date Tokens
- @Procedure Tokens
- @File Upload Tokens
- @Crosstab Tokens
- Other Special Tokens
- Token Encoders
Tokens act as variables in Logi applications and are the primary means of accessing the values of data, request and session variables, cookies, constants, and more. They're resolved into their values at runtime and inserted into the HTML generated by the Logi engine.
Tokens take this general format: @<TokenType>.<Identifier>~ and here are some examples:
They must start with the @ symbol and end with the ~ (tilde) symbol, and they're case-sensitive.
@Data.CustomerID~does not equal@Data.customerid~
That bears repeating as developers typically run afoul of these two things: tokens must end with a ~ and they're case-sensitive.
Logi Studio includes a "token validator" feature. If you enter an invalid token inan attribute value, Studio will display the "Invalid Token" button shown above. In the example, the ~ (tilde) has been left off of the token. Clicking the button will take you to the invalid token(s) in the definition.
Tokens can be used in many, but not all, element attributes to provide a dynamic value. Here are three examples of tokens in action:
1. In the example above, a token is used to provide part of a Label element Caption. At run time, the real server name will be substituted for the token. The output will look like this:
My server name is: MyTestServer
Tokens are extremely literal and are "data type neutral". For instance, in the above example, even though the server name is a string, there is no need to concatenate the "My server name is:" part of the caption (using + or & symbols) and the token.
2. As mentioned earlier, tokens are case-sensitive. In the example above, a Data token is used to represent the value in the ProductID column of each row of data in the datalayer. The spelling and capitalization of the column name in the token must exactly match that of the column name in the datalayer.
3. In our final example, shown above, a token is used in a Division element's Condition attribute. This attribute controls whether or not the Division, and all its child elements, are displayed: if the attribute evaluates to True, it's shown; if it evaluates to False, the element is hidden. A token can be used in this attribute in a formula that evaluates to True or False. More information is available about this in Conditions.
The example uses a Request-type token, which represents data either POSTed by an HTML form or values from parameters in the query string used to call reports. Therefore, if the URL for this report was:
then the Division element would be shown. These URLs:
would cause the Division element to not be shown. If the Mode parameter in the query string is non-existent, as in the third URL above, then the token is empty and the formula evaluates to False.
When you're comparing a token to a string value, be sure to surround the token and the string in quotation marks, as shown in the second set of attributes above.
Logi Studio also includes an "Intelligent Token Completion" feature that makes it easy to enter tokens in attribute values, thus avoiding spelling and case-related errors.