Apply rules to InfoPath form controls


InfoPath form rules help us to perform dynamic actions by applying some simple conditions. Three types of rules are available in InfoPath forms.

  1. Validations.
  2. Formatting.
  3. Actions.

Validations: Validation rules are used to validate user entered data in control. Validating phone number, validation e-mail address etc...

Formatting  formatting rules helps us to change the color, changing background etc.… by meeting certain conditions.

Actions: Performing creating actions by meeting some conditions. Switch views, set field values etc... 

Let's see three types of rules with examples.

Example 1

Validating email address (validation rule). 

Step 1:

Click on email control and select add rules option from top ribbon.

Step 2:

Click on manage rules from the set of available actions.

Step 3:

Name your rule and select validation from the new drop-down.

Step 4:

Go to condition section and prepare a condition.

Step 5:

Click on OK to save changes and enter a screen tip to show as a message if the user enters data in a wrong format.

Step 6:

Go to preview and check whether it works or not by entering wrong emial format.

Example 2:

Formatting mail address text to blue color if it is present (formatting rule).

Repeat step 1 and 2 same like example 1.

Step 3: 

 Select formatting option from rule type.

 I am applying a condition when the mail address is present.

 From formatting selected text color to blue.

 Now the rules window looks like below.

Select the preview option and check the output by entering some text.

Example 3:

Set Mail address field to sample text when the email address is present (action rule).

Repeat step 1 and 2 same like example 1.

Step 3:

Click on email address control and go to rules window and add another rule.

Give a name to the new rule.

Set condition to when the email address is present.

Select rule type to action.

From run these actions section select set a field value action and set mail address field to the sample text.

Click on ok button to save changes. Now rule window looks like below.

Check result by clicking preview option.

Conclusion:

In this post you have seen diffrent category of rules and how to apply them to InfoPath form controls

About Author

Venkat working as an Office 365 and SharePoint consultant. Venkat likes to share Office 365 and SharePoint knowledge through (Videos, Discussions, Tutorials and Blogs).

About Author

Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and  SharePoint Server.He received the MCC award for his contributions in Microsoft MSDN/TechNet forums.He loves sharing articles, videos and tutorial on SharePoint and Office 365.


If you found this post helpful, please share with your friends!!


Join 5,500 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers