Administer > Application setup > Process Designer > Adding a rule > Add a JavaScript Validation rule

Add a JavaScript Validation rule

Applies to User roles: System Administrator

Implementer

This rule allows you to validate any JavaScript code a user enters.

To add a JavaScript Validation rule, follow these steps:

  1. In the System Navigator, click Tailoring > Process Designer > Rule Sets.
  2. Click Search to open the Rule Set form, and then select the rule set to which you want to add the rule.

    Note You can edit user-defined rule sets only. Out-of-box rule sets are labeled as Micro Focus Proprietary and cannot be modified.

  3. Click Add Rule to open the Select Rule Type page, and then click JavaScript Validation.
  4. In the Rule Description field, type a description of your new rule.
  5. Click Edit to add conditions to the rule.

    Note  

    • If you do not specify a condition, the value defaults to Always.
    • You may reference the current record as record in the JavaScript. For example, if the field in a form is a category, it may be referred to as follows: record.category=="xyz"
    • You may reference the original copy of the record (before any changes were made by the user) as oldRecord in the JavaScript (that is 'oldRecord.category').
    • You may set the returnCode variable in the JavaScript to specify whether this rule was successful or should be treated as a failed validation. A return code of 0 (zero) is considered successful (it is the default), any other code is unsuccessful. The return code must be a numeric value.
  6. Note

    • If you do not specify a condition, it will default to Always.
    • You may reference the current record as record in the JavaScript. For example, if the field in a form is a category, it may be referred to as follows: record.category=="xyz"
    • You may reference the original copy of the record (before any changes were made by the user) as oldRecord in the JavaScript (that is 'oldRecord.category').
    • You may set the returnCode variable in the JavaScript to specify whether this rule was successful or should be treated as a failed validation. A return code of 0 (zero) is considered successful (it is the default), any other code is unsuccessful. The return code must be a numeric value.
    • You may set the message variable in the JavaScript to specify a message that displays to the user if the rule is unsuccessful (returns a non-zero return code).
    • You may set the cursorPosition variable in the JavaScript to specify a field on the current form where the cursor should be placed if the rule is unsuccessful.

  7. Enter the JavaScript in the text box.
  8. Click OK to add the new rule to the rule set.

Related topics

Process Designer

Process Designer security model

Create a rule set