Server-side templates can be defined for many API and CLI commands. These templates allow you to control the presentation of the output from the API command. Most commonly this is used to allow the administrator to integrate ExtraView with their company’s own web site. For example, a page within your company’s web site can perform a search of the ExtraView database and return the results formatted with the same look and feel as the web site.
Templates allow you to use "tags" that are substituted at runtime, with the actual value in a record. For example, the tag __STATUS__ refers to the value of the STATUS field of the current issue. Tags are available for most fields in the data dictionary. In addition, if you place a data dictionary field on a template, it must exist on the Detailed Report layout inherited by the specific Business Area and Project. The user must also have read permission to the field.
TEXTAREA, LOGAREA and PRINTTEXT fields have special handling within ExtraView. This is because they can be broken down into three components, the text itself, the user’s name who entered the text, and a timestamp. Each of these components can be accessed individually, as shown in the following example. Note that the field name itself must be included as a tag, although it does not display anything in the output. Therefore, an HTML fragment that might display the DESCRIPTION field may look like:
<TD>
__DESCRIPTION__ __DESCRIPTION.USER__ : __DESCRIPTION.TIMESTAMP__ <BR><BR> __DESCRIPTION.TEXT__ <BR> </TD> |
The full explanation for each part of the field is as follows, where DDNAME is the data dictionary name of the field of display type TEXTAREA, LOGAREA or PRINTTEXT.
Field name | Explanation |
__DDNAME__ | A tag with the data dictionary name must be included in the template. No output occurs with this tag. It is a placeholder that ensures the remaining fields will be processed correctly |
__DDNAME.TEXT__ | This is used to return the body of text within the comments |
__DDNAME.USER__ | This is used to return the name of the user who entered the comment |
__DDNAME.TIMESTAMP__ | This is used to return the date (and time) that the comment was entered. This will be returned in the current user’s date and time format that is defined in their personal settings |
Three special tags are not fields in the data dictionary:
Tag name | Explanation |
__RESULTS__ | this tag returns the result string that is sent, upon execution of a call to the API. For example, if you use an HTML form to insert a record into ExtraView, and define a template that contains only the tag __RESULTS__, then the output would be:
Problem #12342 added. |
__ERR_RESULTS__ | this tag returns any error as a result of executing the API command. It is often used in conjunction with an error handling template, as described below |
__RECORD_COUNT__ | this tag returns the number of records found from the API action named search. You may use this field in the header or footer section of a template (see below), but not in the body part of a template. |
The API commands that work with templates are:
The templates must be stored in a directory in your environment, typically located within your installation in a directory named user_templates. This directory is placed within your ExtraView installation, at the same level as the templates directory that resides inside the WEB-INF directory. This location may vary according to how you installed ExtraView. The ExtraView Administration screens have a feature that allows you to upload files directly to this directory from your local computer.
The template you define can be in one of two forms:
<html> <head> <title>ExtraView Insert Issue</title> </head> <body bgcolor="#FFFFFF"> <p align="center">Thank you for submitting your issue. It has been added to the tracking database with the ID</p> <p align="center"><font color="#000000" size="5"> __ID__ </font></p> <p align="center">Please take note of this number and use this if you wish to inquire about the status. </p> </body> </html> Desired OutputTemplate codeThe template code is split into three files representing the fixed header, the repeating body and the fixed footer. Header File
The fill_in TemplateIt is sometimes useful to be able to generate a template and populate it with values that do not originate in ExtraView’s database. The fill_in action fulfills this need. Syntaxhttp@//www.myserver.com/evj/ExtraView/ev_api.action?user_id=username The template file, this_template.html, will be returned to the user’s screen, with the values for id and any_name_at_all filled in. Template file
Browser OutputThe error.html TemplateIf the code that executes in the API command that was submitted completes with an error or unexpected condition, the template named error.html is invoked and used to display the error to the user. Within this template, the tag __ERR_RESULTS__ is replaced with the actual error message from the command being executed. Template File
Browser Output |