Skip to main content


         This documentation site is for previous versions. Visit our new documentation site for current releases.      
 

Validating field values on a form

Updated on March 29, 2022
Applicable to Hybrid mode applications

Ensure that users enter valid data on a form before the case moves to the next step in the life cycle. By validating field values, you prevent processing errors and speed up the case resolution process. If the data that the user enters on a form at run time meets the condition in a validate rule, the application displays an error message.

For example, you can ensure that the customer provides their name and address before placing an order. If the customer leaves the fields empty, the application displays an error message.
Before you begin: Create a case type, and then define a case life cycle that has stages and processes with assignments. Add fields that you want to validate to the forms in your assignments. For more information, see Automating work by creating case types.
  1. In the navigation pane of App Studio, click Case types, and then click the case type that you want to open.
  2. In the Case life cycle section, select the step to which you want to apply the validation condition.
  3. In the Step properties pane, on the General tab, click Configure view.
  4. Optional: To ensure that the user enters a value in a field before submitting the form, set the field as Required:
    ChoicesActions
    Mark a field as required in a standard Pega Platform application
    1. In the view configuration window, on the Fields tab, locate the field that you want to set as Required.
    2. In the Options list, select Required.
    3. Click Submit.
      When the user tries to submit the form without a value in a required field, the application displays an error message.
    Mark a field as required in a Cosmos React applicationFor more information about defining field behavior in Cosmos React, see Configuring field behavior.
    For example: To prevent the user from submitting a form without entering their date of birth, set the birth date field as Required.
  5. In the view configuration window, define a new validation condition:
    • In a standard Pega Platform application, click the Validations tab, and then click Add condition.
    • In a Cosmos React application, click the Conditions tab, and then click Add condition.
  6. Optional: To display an error message when the validation fails, in the Message field, enter the text of the message.
  7. Define the validation conditions:
    ChoicesActions
    Define a validation condition for a field
    1. In the list of values, select Fields, and then select the name of the field that you want to validate.
    2. In the comparator list, select the test that you want to perform on the field.
    3. In the value field, enter or select a value to compare against the user input.
      The Select values option lists the fields and values that you can use in the condition.
    Apply an existing when condition as a validation condition
    1. In the list of values, select When conditions, and then select the name of the when condition that you want to apply.
    2. In the comparator list, select the test that you want to perform on the when condition.
    For example: To ensure that the birth date is not in the future, select the birth date field from the list, set the is after comparator, and then select Today from the calendar control. When the user tries to submit the form with a birth date that is in the future, an error message appears.
  8. Optional: To create a condition with multiple validation parameters, add a logical operator to the condition:
    ChoicesActions
    Ensure that the condition passes when all properties meet the criteria
    1. Click Add a row.
    2. In the operator list, select and.
    3. In the list of fields, select the name of the field that you want to validate or the name of the when condition that you want to apply.
    4. In the comparator list, select the test that you want to perform on the field or on the when condition.
    5. In the value field, enter or select a value to compare against the user input.
      The Select values option lists the fields and values that you can use in the condition.
    Ensure that the condition passes when any of the properties meet the criteria
    1. Click Add a row.
    2. In the operator list, select or.
    3. In the list of fields, select the name of the field that you want to validate.
    4. In the comparator list, select the test that you want to perform on the field or on the when condition.
    5. In the value field, enter or select a value to compare against the user input.
      The Select values option lists the fields and values that you can use in the condition.
    For example: In a recruitment form, the user must indicate their period of employment at a previous company by entering dates in the From and To date type fields. To ensure that the start date is before the end date, and that the end date is after the start date, you can configure a validation condition with the AND logical operator, as in the following figure:
    Validation of the employment date range
    A validation condition that checks if a date range has a From date after the To date, and a To date before the From date.
  9. Optional: To define more validation conditions, repeat steps 6 through 9.
  10. Click Submit.
Result: At run time, the application evaluates all validation conditions. If the user enters a value that meets any of the validation conditions, the respective error message appears. The user can submit the form after they correct the invalid fields.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega.com is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us