Previous Topic: Use Field Validation ScriptsNext Topic: Print a Form Type


Use Field Event Scripts

The XML file script can contain functions to handle user actions and to respond to these actions. JavaScript listener functions for field changes support user actions (type a character, select from a combo, and so on). The Form Editor invokes listener functions whenever a change is detected in the corresponding form field, and these functions respond to changes in field values by updating the values of other fields.

Use the following naming convention to define listener functions for field changed events:

function [FIELDNAME]Changed

Follow these steps:

  1. Navigate to %AllUsersProfile%\Application Data\CA\SCM\Forms and use a text editor to open the XML file for the form in which you want to define functions.

    The form definition appears in the text editor.

  2. Define the function logic in the form definition within an <events> element.

    For example, if a form includes an mrapplication field, you can define a listener function that responds to its changes as follows:

    <events language="javascript">
       function mrapplicationChanged()
       {
           editor.setTextFieldValue("mrdocument", editor.getTextFieldValue("mrapplication"));
       }
    </events>
    
  3. Define the logic for a formOpened() event function. This function is invoked whenever a user opens a form. For example:
    function formOpened()
    {
        editor.alert("JavaScript formOpened Event");
    }
    
  4. Save the file and resynchronize the form changes with your CA Harvest SCM server.

    The form field is defined to handle user actions.

More information:

How Forms Use JavaScript Scripts