How to make a value selected by default on a parameter on a Jaspersoft report
The steps below illustrate two examples, one for a parameter that uses a static list of values, and one for a query based parameter.
The ‘Sort By’ parameter on the Project Risk Register report is an example of a parameter using static list of values. Out of the box it has ‘Created Date’ selected by default.
Below are steps to change the default to ‘Target Resolution Date’.
Step 1: Locate the ID for available values
1. Log in to CA PPM and navigate to Advanced Reporting > View > Report Repository, expand the folder and locate the report. Click on the space before the report name to highlight it, then click Edit.
2. Click on Controls & Resources:
3. Scroll down to Input Controls and locate the parameter, take note of the path then click Cancel
4. Expand the repository folder following this path and find the Input Control for this parameter, highlight then click Edit at the top
5. On the Edit Input Controls screen, click Next to get to the List of Values screen, take note of the path for values, then Cancel out of this screen
6. Expand the repository folder using this path, highlight and click Edit at the top:
7. Take note of the Value for the parameter value you want. Value is actually a unique ID for the lookup value, not its name. It can be different from the displayed text you may see from the report parameter drop down.
In this example, “Target Resolution Date” is displayed on the report parameter, while its Value (ID) is “TARGET_RESOLUTION”. After copying the text for ‘Value’, cancel out of here.
The example parameter ‘Sort By’ shown above uses a static list, all available values are conveniently listed here in the report repository.
If the parameter uses a query instead, the available values are not presented in a convenient list but stored in a database table as the values can change depending on the underlying query. To identify the exact table and column used for the parameter, check the Input Control.
Take a query based parameter Risk Status as an example, its Input Control is /ca_ppm/input_controls/common/riskStatusKey_1 .
1. Use this path to locate the key and review the Value Column which indicates the table column name.
2. Next find out the which table this key is selected from by reviewing the query by going to /ca_ppm/Input Controls/Queries
3. Click Edit to get to the Query definition, we see that the table used for the example parameter is DWH_LKP_RIM_STATUS
4. Finally use a SQL query tool to query the table for the column data type as well as all available values. The values can then be used when modifying the Default Value Expression in the following steps.
Step 2: Save a local copy of the report before making any change
By saving changes locally and uploading back up to the original report, you can avoid some potential issues with corrupting main report or breaking sub reports in Jaspersoft Studio.
1. Launch Jaspersoft Studio Pro, locate the report.
2. Right click on the main jrxml and select Download to File, and proceed to save it locally to your workspace. Avoid spaces in report name.
3. Upon saving, Jaspersoft Studio will open this local copy. Modify this local copy
Step 3: Modify the parameter default value in the local report
Expand the Parameters list and highlight the parameter, the properties of the parameter is populated on the Properties tab on the right. Notice that the current default value is ‘Created Date’. Click on the pencil icon for Default Value Expression
A popup opens up showing the current default:
Replace the text inside the double quotes with the text previously copied from the parameter Value column, then click Finish:
If the parameter has multiple values set for default, like the second example parameter ‘Risk Status’, an ArrayList is used.
•Refer to community.jaspersoft.com for further information on building expressions.
Step 4: Save the change and upload the local copy back to the server
Save the local report without publishing to the server. Right click on the report’s main jrxml again, select Properties. The Edit Resource popup opens, click on the drop down for Upload\Download Resource, then select Upload from File System
Locate the file that was previously saved and click Open, and Finish.
Finally, log in to CA PPM to verify the change.
For the first example, Target Resolution Date is now selected by default for the Sort By parameter for the first example shown above.