Changes

Jump to: navigation, search

Modify an iReport Template

357 bytes added, 22:36, 19 September 2013
no edit summary
|[[Summarize i-Report Template Data|Summarize i-Report Template Data]]
}}
==Overview==__NOEDITSECTION__
Once an iReport template has been created, there are many options for modifying the report template including adding new fields, creating variables, filtering the query results and many other options. This section covers the main customizations performed on iReport templates for use in {{IMSMANG}}
==Fields, Variables, and Parameters==__NOEDITSECTION__===Adding a Field to an iReport Template===__NOEDITSECTION__
<p>If you need to include a field that was not selected while using the Report Wizard, there are several options for including additional fields. The definition of a field
====Option 1: Get fields from Datasource====__NOEDITSECTION__
Using the Report Query dialogue, you can select the option to Get Fields from Datasource Provider, which will automatically add all fields from the selected datasource to the report template. You can then remove any unwanted fields from the report {{warning | Make sure that the datasource selected in iReports corresponds to the data source for the report}} To add fields from the Report Query dialogue:
# Choose the Report Query button
# Choose '''Ok''' to save the fields and return to the iReport Designer.
====Option 2: Copy and Paste====__NOEDITSECTION__
Alternatively, you can create a new report template using the Wizard and add the desired fields to the new report. Fields can then be copied and pasted from the new report to the original report.
# Create a new report using the [[Create a Basic i-Report Template|iReport Wizard]] and the same data source
{{note | It is not recommended to the use the "Add Field" option from the Report Inspector due to the complexity of adding the correct field attributes and properties.}}
===Adding a Parameter to an iReport Template===__NOEDITSECTION__
It is sometimes necessary to add a parameter to an iReport template. Usually parameters are used for transferring data from a main report to a subreport. Below are the steps to add a parameter to an an iReport Template.
# From the Report Inspector, '''right click''' on the '''Parameter''' tree and choose '''Add Parameter'''.
#: [[Image:IReport AddParameter2.png|center|250px|''Add Parameter'']]
===Adding a Variable to an iReport Template===__NOEDITSECTION__
Often it is necessary to add a variable to an iReport template. Variables are used to store calculations and totals in an iReport template. They are often used in the Summary Band portion of a report to store sums of numeric fields (e.g. areaSize) or record counts. There are two main ways to add variables to an iReport template.
====For numeric variables====__NOEDITSECTION__
For variables that are numeric (area sizes, number of devices, etc):
# From the '''Report Inspector''', Select the field that you wish to sum or count.
#: [[Image:IReport VariableAdd2.png|center|300px|''Select aggregation function'']]<div align="center">''Choose the type of calculation''</div>
====To add a variable manually====__NOEDITSECTION__
This may be required when adding more complicated variables such as variables designed to perform calculations on one or more fields or when using fields that are not numeric.
# From the '''Report Inspector''' '''right click''' on the '''Variable''' tree and choose '''Add Variable'''.
# Drag the variable to iReport template as desired.
==Report Query Filtering==__NOEDITSECTION__
iReport Designer provides an option for limiting or filtering the results of the query that returns data to the report. While in most cases this Report Query filter is ignored by {{IMSMANG}} once the report as been imported in favor of the search criteria, there are some cases where it is important to edit the Report Query filters in iReport. The two main reasons are:
* '''temporarily''': to limit the results returned when previewing the report during the design phase in iReport
Both approaches use the same steps.
===Using Report Query filters===__NOEDITSECTION__
To use Report Query filters,
# Choose '''OK''' to save the Report Query settings and return to the report.
===ImsmaQuery Language Syntax===__NOEDITSECTION__
The ImsmaQuery Language syntax is a language designed to limit or filter datasets in iReports. It is similar to the WHERE clause syntax in SQL though not identical. ImsmaQuery language generally uses the following format:
''field'' OPERATOR "''value''"
localId IN ("value1", "value2", "value3")
====ImsmaQuery Examples====__NOEDITSECTION__
localId LIKE "MF-HQ-%"
endDate > 2010-09-01 AND endDate <2010-09-30
Strings from lookup tables (i.e. ImsmaEnum) should always refer to the key value rather than the translated value.}}
==Special Fields ==__NOEDITSECTION__
In addition to providing access to all of the data fields on a particular object, the iReport data sources provide access to several special fields to access hard to reach data from the IMSMA database.
===The SQL Field===__NOEDITSECTION__
Most iReport data sources have access to a special field called the SQL field to access hard to reach data. This field allows report designers to insert and execute an SQL query to access data from within an iReport template. It's usage requires a knowledge of SQL and the IMSMA database structure and is only recommended for IMSMA administrators with a strong information management background. In most cases the field has the name in the form of:
''[object]''SQLField
# Return to the report and use the new SQL Field just like any other string field.
====SQL Field Examples====__NOEDITSECTION__
The SQL statement can be any valid SQL statement that returns a result. This field can be used to retrieve data that is otherwise difficult to access areas of the database. You can use any valid PostgreSQL statement in the SQL field including
* VIEWS, JOINS, HAVING, sub-selects, and sub-queries
ordnance_guid IN (SELECT ordnance_guid FROM ordnance WHERE model LIKE '%AP%')
===links.toGuid===__NOEDITSECTION__
Another example of a special field available in iReport templates is the '''links.toGuid''' value. links.toGuid is available on any of the major objects in {{IMSMANG}} including Land, Activity, Education, Accident, Victim, Assistance, Location, and Quality Management. This field can be used in the Report Query portion of a report to filter the results based on linkages to other objects. For example, on a Land report with an Activity subreport, the subreport could contain the following Report Query filter to return only Activities with linkages to the Land on the main report:
links.toGuid = "$P{HazardGUID}"
As with other areas in iReport, the ''links.toGuid'' field is case sensitive and must be referenced exactly,
==Sorting and Grouping==__NOEDITSECTION__
===Grouping===__NOEDITSECTION__
Grouping allows you to organise the report results using the values of a particular field. Grouping results makes it easier to identify the records which share a common value. Rather than having to visually scan the report results to determine which records have a common value, grouping automatically organises the results for you.
</div>
===Adding a Group to an iReport Template===__NOEDITSECTION__
{{note|The field on which you would like to group your report results must be included in the report.}}
This will create a new group in the iReport template as well as two additional bands (a header and a footer for the group).
===Sorting Report Results===__NOEDITSECTION__
It may be helpful to sort the report results using the value in one or more of the fields. Sorting the results makes it easier to review the results and locate any records that you may be searching for.
To sort report results:
4,913
edits

Navigation menu