Previous Topic: How Forms Use JavaScript ScriptsNext Topic: Use Field Validation Scripts


Use Initialization Scripts

Initialization scripts let you perform custom initialization of form field values. Thus, when a user opens a form in the Form Editor, the field value is set to its initial value. A field can have both an initial value and a current value, both of which are character strings. A field's initial value does not change unless the user edits it. Edited form values are not stored in the database until a user saves the form.

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 set initial values.

    The form definition appears in the text editor.

  2. Define the initialization logic in the form definition within an initialization element.
       <initialization language="javascript" client="eclipse">
      editor.setTextFieldValue("mrcomponentname", "JavaScript value");
    </initialization>
    
  3. Save the file and resynchronize the form changes with your CA Harvest SCM server.

    The initial values for the form field are set.

Example: Define Initialization Logic

An example of an initialization logic definition follows:

<initialization language="javascript" client="eclipse">
   editor.setTextFieldValue("pacinitiator", "Hello");
editor.selectTab("Change Evaluation");
editor.setFocus("pactestplan");
</initialization>

When a user opens a form in the Form Editor, this block of JavaScript code is invoked and the form shows:

More information:

How Forms Use JavaScript Scripts