Validating user input (deprecated)

Draft comment:
This topic only applies to BAW, and is located in the BAW repository. Last updated on 2025-03-13 12:15
Add validation scripts for button controls in heritage coaches to ensure that users provide all required input.

About this task

When building heritage coaches in IBM® Business Automation Workflow, you can add client-side validation scripts for button controls. Validation scripts ensure that users provide all required input. If not, the script provides the appropriate feedback to prompt users for the required information.

Procedure

  1. Open the service that contains the heritage coach that you want to work with and then click the Coaches tab.
  2. In the design area, click to select the control for which you want to add a validation script.
  3. Click the Presentation option in the properties.
  4. If multiple buttons are included in the control, under Buttons, click the button that needs the validation script.
  5. In the text box under the Validation Script section, type the JavaScript to validate that the required controls have been set and contain values as expected.
    To do this, use the control ID of each required control. The following example is client-side JavaScript that uses the default controls included when you add a new heritage coach to a service. The following validation script checks to ensure that the check box is enabled (set to true). If not, the user is prompted to check it before proceeding by clicking OK.
    if ( document.getElementById("checkbox0_checkbox").checked == true ){
      return true;
    } else {
      alert( "Check the checkbox");
      return false;
    }
  6. Save the heritage coach and then run the service to test the script.

What to do next

In many cases, an OK or Submit button that runs a validation script on the user input is accompanied by a Cancel button which discards the user input. When Is Cancel is selected for a button, clicking the button discards any changes to variable values, and moves the token to the next step in the flow.