Form design notes - data validation

SAP Data Validation

When using Microsoft InfoPath you can enable the SAP validation from one of the two Transaction script options in the form. (see Script Design Notes).

Option 1: Use an update script with the validation feature turned "on", the validation field is displayed in the InfoPath form as a checkbox. You can set the default for this checkbox to always be "on" (selected) and remove the field from the form view. When a user clicks on the Web service button (which you can label as "validate"), it will only validate data and not post it to SAP.

This is usually done for users who need to only validate data and not update SAP. If the user needs to have the option to validate and update, then show the validate checkbox on the form view so the user can set it appropriately.

Option 2: Use a script that will only validate. Note this script will not have a validation checkbox. The only way to run this type of script is by clicking on the Web service button, which can be labeled Validate. This type of script will not allow any posts to SAP—you will need to use a different script to post to SAP.

Non-SAP Data Validation

As you design a Web form, you can use and maintain business value-added rules (that are not covered by SAP) with the Microsoft InfoPath rules editor. Below are some methods for doing this.

Required Field Validation

One type of field validation is to require a value to be entered (i.e. the field cannot be blank). To do this in InfoPath:

  1. Right-click the desired field, and then select Properties (e.g. Text Box Properties or Drop-Down List Box Properties)
  2. On the Data Tab, under Validation, check the box labeled Cannot be blank.

Field Validation Rules

Rules can be added to validate data entered into a field on a field-by-field basis. To add a validation rule:

  1. Click on the field on the form view where the rule should be added
  2. On the InfoPath menu bar, click Properties, and then click Manage Rules. This will expand a section called Rules on the right hand side of the screen.
  3. Under the Rules section on the right hand side Click New, and then click Validation.
  4. Under the Rules section, under Condition click none (because you have not define the condition yet) - you will see a pop up like the one below where you can define the rule. Note you can use the AND or OR operators if needed.

Formatting and Action rules

You can also use rules for formatting, such as hiding sections or fields, or actions such as setting a field value based upon data in another form. (See Dynamic Default Values)

Pick list values

Setting pick lists values can also be viewed as a form of field validation to aid the user in filling out a form. See Populating Picklists on a Form for more information.

Form Validation

Form validations can be used to validate data in a number of ways. One example of a form validation is requiring a user to receive a "success" message back from SAP prior to routing the form to the next participant. This can be done through a Winshuttle Custom Control called Ws.FormValidation.

  1. Add the control to the form
  2. Right-click to open the properties box.
  3. Write an express that must be true for the validation to be valid.
  4. Write a messages that is displayed when the expression is false.

    This example shows two fields being compared.

The ValidateTest field has a "success" value. Therefore, the logfield_3 must have "success" before the form can be routed onto the next step. Additionally, when the field comparison is not true a message can be displayed to the user explaining what condition must be met. This message can be typed below under the Message column.

See the following Web sites for additional help working with Regular expressions to aid in Form Validation.

Regular Expressions.Info

Regular Expressions Library