Processing a Form in a Report

A form is processed and submitted to the server whenever a “submit” action occurs on the form (e.g., 'Submit' button is pressed or an 'onSubmit' script returns “true”). The submission contains a single repletRequest object that includes all form values.


Register Report Tool Demo

Scripting the onClick Handler

To process the form on the server end, add script to the onClick Handler handler of the Form elements. To do this, open the Form in Report Designer, and follow the steps below:

  1. Select a form element to which you want to add an 'onClick' script.
  2. Note: This is the server-side 'onClick' handler, not the client-side 'onClick' handler described in Creating a Form. You can also edit the server-side 'onClick' handler from the tabbed panel at the bottom of Report Designer window. You can add 'onClick' script to any Form element. (If you add 'onClick' scripts to multiple elements, all of these scripts are executed when the form is submitted, and all have access to the same set of form values.)

  3. Right-click the Form element, and select 'Script' from the context menu. This opens the Script Editor.
  4. Select the onClick tab at the top of the Editor.
  5. Enter the commands to be executed by the report server when the form is submitted. See Server-Side JavaScript below for more details.

Server-Side JavaScript

The server-side 'onClick' script has access to a RepletRequest Object containing all form element values. You can access a particular field value by using the element 'Field Name' as index:

request['FieldName']   or   request.FieldName 

Field names must be unique within a form (with the exception of Radio Buttons). If there are multiple “submitting” form elements, use 'request.__eventSource__' to obtain the field name of the element that triggered the submit action. For example:

 if(request.__eventSource__ == 'Choice1') {
    ...
 }
 else if(request.__eventSource__ == 'Button1') {
    ...
 }
 else {
    ...
 } 

Note: If the 'onClick' script of a form element on a Parameter Sheet calls the sendRequest() function, the submission from sendRequest() is sent in place of the normal form submission request. If your script modifies element values and needs to refresh the screen, it should call the reprint() or refresh() function. The 'reprint' action causes the report pages to be regenerated without refreshing the data binding. The 'refresh' action forces the report data to be refreshed before the report is reprinted. If the onClick Handler does not change the data or the way the data is bound to report elements, the reprint action is sufficient.

Summary

Style Intelligence offers advanced scripting capabilities that support dynamic report modification without requiring programming. Scripts can be applied to the whole report or to specific elements. Scripts can modify element properties, change data, pass parameters to reports, and more.

Previous: Interactive Forms in a Report