Using templates with fields
Binding a template to a view field
To use a template to display in a view field without workflow, set the Text property of the view field to template: templateName. (See View-fields.) The parameters in a template used this way must reference fields on the form by field ID. An application can create a rich HTML-based data display using a cell-based table with data fields and a view field with a template bound to it.
To redisplay a view field with a template bound to it, for example, after one of the referenced fields has its value changed, use workflow to assign the value of the view field to itself or to a value generated by the TEMPLATE function, as describe in the next section.
Click
to download the sample template. Perform the following steps:- Create an HTML template (for example, sample_template_0.html).
- Create a new entry and attach the template to the AR System Resource Definitions form.
- Update Text property on your view field to name of the resource (for example, template:SampleTemplate).
Evaluating a template using the TEMPLATE function
Use the TEMPLATE function to set the values of a field to the result of evaluating a template. The TEMPLATE function can appear in a field value in a Push Fields, Set Fields, Open Window, or Service action. The TEMPLATE function returns a text string with values for the parameters included in the template. The template name is always the first parameter, followed by name-value pairs for the remaining parameters, as follows:
TEMPLATE(" templateName", " parameter", " value", " parameter", " value", ...)
Templates can be nested within templates using either of the following methods:
- By using workflow to generate content from a template with an HTML snippet and placing it into a hidden field. The value of that hidden field can be passed to another TEMPLATE function.
- Using the TEMPLATE function as a parameter within another TEMPLATE function.
At runtime, when the client (the Mid Tier) executes the active link where the template is specified, the template is retrieved from the AR System server and processed for the parameters that should be substituted. The resulting information is then rendered either in a view field or as a value in a character field.
If the template does not use explicit parameters, it can be evaluated by calling the TEMPLATE function with only the name of the template.
A message action of the type Tooltip can display the HTML generated by a Set Field action. This is typically done using a Set Fields action (generating content into a hidden field), followed by a message action to display the content of the hidden field.
The Remedy Developer Studio Expression Editor includes a mapping tool for setting template parameter values. After you select the TEMPLATE function, select a template from the Template Name list. The explicit parameters are listed in the table below. If you select the Value cell and click the ellipsis button, you can open an editor to set the value. See the following figure.
Using auto-complete functionality with the TEMPLATE function
You can also use the auto-complete feature in the text portion of the Expression Editor. When you enter Ctrl+Space over the template name, a list of available templates appears.
Using auto-complete for template information