Special Fields
This topic introduces special fields.
Below is a list of the sections covered in this topic:
Special Fields Supported by Logi JReport
Special fields are defined by Logi JReport and allow you to easily obtain system information and report-related data and add it to your report. The special fields are as follows:
Date-time
Lists all the datetime type special fields.
- Print Date
Prints today's date (or the current date from your computer). - Print Time
Prints the current time from your computer. - Fetch Date
Prints the date when the data is retrieved from the database. - Fetch Time
Prints the time when the data is retrieved from the database. - Modified Date
Prints the last modified date of the catalog. - Modified Time
Prints the last modified time of the catalog.
Computed
Lists all the special fields that are computed based on the report.
- Record Number
Prints the record number (usually placed in the Details panel). - Group Name
Prints the group name (usually placed in the Group Header/Footer panel). - Total Records
Prints the total number of records after all the filter conditions are performed, except the ones created in the Filter dialog of Page Report Studio, and the Group Filter dialog and top N or bottom N condition in Logi JReport Designer. - Total Fetched Records
Prints the total number of records which take part in grouping calculation. The possible result of the special field is as follows:- If you don't set any filter condition in the Filter dialog of Page Report Studio, print the number of the record obtained after setting the property Maximum Records.
- If you set filter conditions in the Filter dialog of Page Report Studio, print the number of records obtained after performing the filters, even though you have set the property Maximum Records before setting the filters.
- Group Number
Prints the group number (usually placed in the Group Header/Footer panel). - Total Group Number
Prints the total group number (usually placed in the Group Header/Footer panel). - Page Number
Prints the page number of the component which it is placed in. - Global Page Number
Prints the global page number of the whole report wherever it is placed. - Total Page Number
Prints the total number of pages of the component which it is placed in. - Global Total Page Number
Prints the global total number of pages of the whole report wherever the field is placed. - Page N of M
Prints a specific page number out of the total page number of the component which the field is placed in. You can specify the format of this special field. To do this, select this special field, then in the Report Inspector, find the Format property and choose an item from the shortcut list. Besides the items listed here, you can also customize the format. For example, if you want it displayed as "This is page n of m pages", you can input the format string "This is page @PageNumber of @TotalPageNumber pages" into the Format text box. - Global Page N of M
Prints a specific global page number out of the global total page number of the report. You can specify the format of this special field in the Report Inspector. The operation is the same as Page N of M. - SQL Statement
Prints the SQL statements used to execute the query. This is often useful for resolving performance issues as you can see exactly what is passed to the database after all the parameter substitutions and filters are applied.
System
Lists all the special fields which get values from the system.
- User Name
Prints the User ID. When viewing the report in Logi JReport Designer, it returns the name specified for the User Name option in the General category of the Options dialog, while when running the report on Logi JReport Server, it returns the name used to log onto the server. The User Name special field can be used in different data sources as follows:Filter Condition HDS (General) HDS (XML) UDS SQL File JSON User Name Supported. Supported in the Parameter box in the New General Hierarchical Data Source dialog. Supported. Supported in the Parameter box in the New User Defined Data Source dialog. Supported in the SQL statement. Supported in the Instance box in the Extract JSON Schema screen of the JSON Connection Wizard and the Value column of the HTTP headers and HTTP body in the RESTful Data Source Options dialog. User Name used in a formula Supported. Supported. Supported. Supported. Supported. Supported. It should be used as username in formulas and stored procedures and as @username in UDS, imported SQL, JSON and filter conditions. The user name used to log into Logi JReport Server will be applied at runtime.
- Task ID
Prints the internal task ID (a unique time stamp). This special field only works in the Logi JReport Server environment. It returns a NULL value when running in Logi JReport Designer. - Report Path on Server
Prints the full path of the report in the Logi JReport Server resource tree. If the report is not running on Logi JReport Server, it returns the full disk path of the report. It returns a NULL value if the report is unsaved. - Report Path on Disk
Prints the full disk path of the report. It returns a NULL value if the report is unsaved. - Catalog Path on Server
Prints the full path of the report's catalog in the Logi JReport Server resource tree. If the report is not running on Logi JReport Server, it returns the full disk path of the catalog. It returns a NULL value if the report is unsaved. - Catalog Path on Disk
Prints the full disk path of the report's catalog. It returns a NULL value if the report is unsaved.
Notes:
- You can insert all special fields into web reports and library components in Logi JReport Designer. However, due to the characteristics of Web Report Studio and JDashboard, only these can be rendered and edited at runtime: User Name, Modified Date, Modified Time, Fetch Date, Fetch Time, Print Date, and Print Time.
- Page Number, Total Page Number and Page N of M in the following conditions in versions after V8 are different from those in versions prior to V7:
- In V7 and prior, the Page Number, Total Page Number and Page N of M which are placed in a subreport will calculate the page number of the subreport if the value of the property Embed in a subreport is set to true. And if you set Embed to false, the Page Number, Total Page Number and Page N of M will work as global special fields, it will calculate the page number of the primary report.
- While in V8 and after, the Page Number, Total Page Number and Page N of M which are placed in a subreport will calculate the page number of the subreport no matter how you set the property Embed to true or false.
Inserting a Special Field into a Report
Special fields can be inserted in the report areas listed in Component placement.
To insert a special field into a report:
- Position the mouse pointer at the destination where the special field is to be inserted.
- Select Insert > Special Fields or Home > Insert > Special Fields, and select the required field from the drop-down menu.
Referencing Special Fields in a Formula
Some special fields can be used in formulas. They are User Name, Print Date, Print Time, Fetch Date, Fetch Time, Modified Date, Modified Time, Record Number, Page Number, Global Page Number, Total Records and Total Fetched Records. They can all be divided into two types (page level and constant level) according to the time when their values are ready.
Page level
The value of this special field is ready at the time when the report result is generated. A formula which references a page-level special field is treated as a page-level formula. In which, the formula is calculated more than once.
The special fields of this type are: Fetch Date, Fetch Time, Print Date, Print Time, Record Number, Page Number, Global Page Number, Total Records and Total Fetched Records.
Constant level
The value of this special field is ready at any time before the engine runs. A formula which references a constant-level special field is treated as a constant-level formula, and is calculated only once.
The special fields of this type are: User Name, Modified Date and Modified Time.
Changing the Display type of a Special Field
The display type of a special field can be changed, that is to say, you can map the special field to another value or image to be displayed instead.
To change the display type a special field:
- Right-click the special field and select Display Type from the shortcut menu.
- In the Display Type dialog, specify the required display type in the Display As box and set the options for the selected type in the Web Options panel.
- Upon finishing, select the OK button to close the dialog.
For details about display types, see Changing the Display Type of a Label.
Applying Web Actions to a Special Field
A special field can be bound with web actions. This allows you to customize a special field to make it respond to interactive events, and execute corresponding actions, such as sorting and filtering.
To apply web actions to a special field:
- Right-click the special field and select Display Type from the shortcut menu.
- In the Web Behaviors box of the Display Type dialog, choose an event from the Events column, then select in the Actions column and select that appears in the text box.
- In the Web Action List dialog, select a web action and define the action as required.
- Select in the Display Type dialog to add more web behavior lines and specify the events and actions accordingly. If a web behavior is not required, select to remove it.
- Adjust the order of the added web actions by selecting or . Then, when an event that has been bound with more than one action happens, the upper action will be triggered first.
- When done, select OK to accept the settings.
For more information about web actions, see Applying Web Actions to a Label.
Binding a Link to a Special Field
You can make a special field link to another report, a location specified by a URL, an e-mail address, or a Blob data type field. The link can either be a simple link or a conditional link. With conditional links, different targets can be loaded based on different conditions.
To bind a link to a special field:
- Right-click the special field and select Link on the shortcut menu.
- In the Insert Link dialog, specify whether it is a conditional link or a simple link, then select the link target and set the options for the link target as required.
- When done, select OK.
For details about different link targets, see Binding a Link to a Label.
Adding Conditional Formats to a Special Field
You can add conditional formats to a special field, then when a specified condition is fulfilled, the format bound with the condition will be applied to the field values automatically. However, conditional formatting applies only to the two special fields: Page Number and User Name.
To add conditional formats to the special field Page Number/User Name:
- Right-click the special field and select Conditional Formatting from the shortcut menu.
- In the Conditional Formatting dialog, select the button to add a condition.
- Set the format that will be applied to the field values when the specified condition is fulfilled.
- Repeat the above two steps to add more conditions and define the format for each condition.
- When done, select OK to save the settings.
For more details about conditional formatting, see Adding Conditional Formats to a DBField.
See an example: The SampleComponents catalog, included with Logi JReport Designer, contains reports that have examples of how each component type could be used in a report. For the special field example, open <install_root>\Demo\Reports\SampleComponents\ForSpecialFields.cls
.