Creating and using string tokens
You can create your own string tokens. A string token is like a global variable in a programming language; it evaluates to an actual value at runtime. You can use string tokens in templates and formulas. See Adding business logic for details about where you can use templates and formulas in a Platform application.
String tokens are useful for holding text that one or more applications in a tenant use frequently and that is displayed by code in a template or a formula. For example, you might create a string token and use it to display a company name. If the company name changes, you only have to change the string token to change it in all applications in the tenant.
String tokens support values in multiple languages for tenants that support multiple languages. See Language support for information about support for multiple languages. See Creating and using multilingual string tokens for information about storing string token values in multiple languages.
Every string token you create is available to any application in the tenant. You must attach a string token to any application that uses it before publishing or exporting the application. See Attaching string tokens for details.
The following example walks through the steps to create a string token for a tenant and use the string token in an HTML component on a page.
To create a string token:
- Navigate to a location where you can edit a template or formula.
- From the Template Helper, click
String Tokens.
- Click Add.
- Enter the string token value and a Token Name. The following screen shows an example string token that evaluates to a welcome message for the Lending Library application:
To use a string token in a template or formula:
- Click String Tokens to find the name of the token you want to add.
- Click the token name; the syntax for using the token appears in the Template Helper:
- Copy the token from the Template Helper and paste it into the editor
pane where desired. You can format the token's appearance as shown in the following
screen:
- When you have finished editing the HTML component, save it.
- Click Save in the page editor.
Platform will render the above HTML component on the application page. The screen below shows the resulting text:
To include string tokens in a published application, you must attach the string tokens to the application. Follow these steps to attach string tokens to the application:
- Navigate to the application's setup screen.
- From the More actions menu, select String Tokens. The Attach String Tokens screens opens.
- Select the string tokens to attach to the application from the
Available column and use the arrow to
move them to the Attached column.
- Click Save.