Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

In addition to validation and formatting rules, you can also add rules to form templates to perform other actions, such as switch views, set a field value, or query or submit to a data connection. For example, you could design a form so that the data users enter into it is automatically saved to SharePoint, without clicking Submit, or to switch from one view to another when a button is clicked.

These rules can be activated by changes to a form field, clicking a button, inserting of a repeating section or row in a repeating table, or the opening or submission of a form. These rules check for conditions based upon the data in the form, the user role, or the value of a field. They can also run without any conditions needing to be set.

You can also add multiple actions for each rule. For example, you can add a rule to a button that submits the data that was entered, and then switches to a view that displays a message to confirm that the data was submitted.

In this article

Action rule types and examples

Show a message

You can add a rule that opens a dialog box if a certain condition in the form is met. For example, in an expense report form if the user enters a value that exceeds a specific amount a message can appear. Show a message actions are only supported in InfoPath Filler forms.

Show the value of a field or formula

This action enables you to add a rule to display the value in a field or a calculation based on the values of different fields on the form. For example, a user can be advised that the arrival date in a hotel expense must be before the departure date by using the dates entered by the user. Show the value of a field or formula actions are only supported in InfoPath Filler forms.

Switch views

Views can be switched when a button is clicked. This enables users to navigate through two or more views by clicking back or next. You can also add a rule to switch the view when the form is opened. For example, views can be switched based on the role that is associated with the user that opens the form. Switch views actions are only available on buttons and Form Load.

Set a field’s value

Using a rule to set the value of a field allows you to dynamically change values in a form. For example, in an expense tracking form where users enter an expense item and the amount of the expense, a Total field can track the total of entered expenses. Instead of having users manually enter the total of all expenses, the set a field’s value action can automatically set the value of the Total field.

Query for data

The query for data action enables you to query an external data source for information. For example, you can add a query for data action that initiates a query to a database to retrieve employee information when a user enters his or her employee number in a form.

Submit data

A submit data action rule submits all of the data in a form. For example, using the submit data action, you can add a rule to a form template for a permit application that submits the data in the form to both a Web service and a database when the user clicks a Submit button on the form.

Open a new form to fill out

Open a new form to fill out enables you to add a rule that opens a new copy of a form that is based on this form template or another form template. For example, you can add this rule to a form template for a permit application to do the following: If the value in an expenses field exceeds a fixed amount, the rule opens a new form that requires an itemized entry of expenses. Open a new form to fill out actions are only supported in InfoPath Filler forms.

Close the form

The close the form action enables you to add a rule that closes the form when a specified event occurs on the form. For example, you can add a rule that closes a form after the user submits the form and the external data source confirms that the form was successfully submitted. Close the form actions are only available on buttons.

Send data to Web Part

You can enable your form to send data to SharePoint Web parts by adding the send data to Web part action. When an InfoPath Web browser form is hosted inside the InfoPath form Web part on a SharePoint page and a connection has been configured with another Web part, this rule initiates sending the data in the InfoPath form to the connected Web part. For this rule action to function correctly, fields in the form must be promoted as Web part connection parameters. In SharePoint list forms, all fields are automatically promoted as connection parameters.

Sign signature line

The sign signature line action enables you to add a rule that, when triggered, opens an indicated signature line control for the user to sign. For example, if you have a signature line control on the form, and you add the sign signature line action to the submit button, then when the user clicks the submit button they are asked to sign the signature line control.

Data Connections

If you add an action rule to query data, submit data, or submit data to a Web part, then it is best to already have the desired data connection in place before the rule is added. 

Add an action rule

Use the Add Rule button

Included, pre-defined rules can be added by clicking Add Rule.

  1. Click the control that you want to add the action to.

  2. On the Home tab, in the Rules group, click Add Rule.

  1. In the If column, click the type of condition that the rule must meet, such as Is Blank.

  2. In the Actions column, click an action, such as Submit Data. Depending on the condition selected, additional information might be requested.

  3. Do the following, depending on the type of action you are adding from the Rule Details window:

  • Show a message

    • In the Message field, type the text for the message, and then click OK.

  • Show the value of a field or formula

    1. Either enter the expression in the Expression box, or click Function next to the Expression box to build your expression, and then click OK.

      For more information regarding formulas, see Add functions and formulas.

  • Switch views

    • In the Rule Details dialog box, click the view that the user will switch to when the action is initiated from the View box.

  • Set a field’s value

    1. Click Field next to the Field box.

    2. Click the field to select it.

    3. Click OK.

    4. In the Value box, type the value, or click Function next to it to enter a formula.

      Note: For more information regarding formulas, see Add functions and formulas.

  • Query for data

    • Click a receive data connection from the Data connection field or click Add to add a new data connection.

      For more information regarding data connections, see Data connections overview.

  • Submit data

    • Click the submit data connection from the Data connection field or click Add to add a new data connection.

      For more information regarding data connections, see Data connections overview.

  • Open a new form to fill out

    • Enter the template ID or the location of the form template in the Form Template ID or Location box, and then click OK.

  • Close the form

    • Click OK if this is a Web browser form or, if this is a Filler form, you can optionally select the If changes have not been saved, prompt the user to save check box to prompt users to save the form before it is closed.

  • Send data to a Web Part

    1. Click Property Promotion to select the fields that should be promoted as Web part connection parameters.

    2. Click Add next to the list of SharePoint Web part connection parameters to display the Select a Field or Group dialog box.

    3. Click a field.

    4. In the Parameter name box, enter a name for the parameter.

    5. Click OK.

    6. Repeat steps 2 through 5 to promote additional fields.

  • Sign signature line

    Important: Before adding a sign signature line rule, make sure that you have added a signature line control to the form so that there is something for the rule to sign.

    1. Under Sign the first signature line where, in the list, click the method of indicating which signature line from the form should be signed.

    2. In the is equal to box, enter the criteria or click Function to use a function for the criteria.

    3. Indicate whether or not a default signature image should be used and whether or not the signature line is in the host document, and then click OK.

      For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.

  • Click the Don’t run remaining rules if the condition of this rule is met check box if you want to stop processing additional rules.

Use the Rules task pane

Do the following to add an action rule from the Rules task pane:

  1. Click the control that you want to add an action rule to.

  2. If the Rules task pane is not visible, then, on the Home tab, in the Rules group, click Manage Rules.

  1. Click New.

  1. Click Action.

  2. In the Details for text box, enter a name for the rule.

  1. Under Condition, click None.

  2. Select the correct options as follows:

    • If the condition for your rule is based on a field:

      1. Click a field or click Select a field or group.

      2. Click the operator, such as is equal to.

      3. Enter the criteria for the operator.

    • If the condition for your rule is based on an expression:

      1. Click The expression.

      2. Enter the expression.

        For more information, see Add functions and formulas.

  1. Click And to add another condition and repeat step 7 or click OK when done adding conditions.

Note: After adding a second condition, the And button is replaced with a box. Leave and selected if both the first and each subsequent condition needs to be true for the data validation to be applied. Otherwise, if only one of the conditions should be true for the data validation to be applied, click or.

  1. On the Rules task pane, click Add, and then click the type of action rule that you want to add.

  2. Do the following, depending on the type of action you are adding.

    • Show a message

      • In the Message field, type the text for the message, and then click OK.

    • Show the value of a field or formula

      • Enter the desired expression in the Expression box, or click Function next to the Expression box to build your expression, and then click OK.

        For more information, see Add functions and formulas.

    • Switch views

      • In the Rule Details dialog box, click the view that the user will switch to when the action is initiated from the View box.

    • Set a field’s value

      1. Next to the Field box, click Field .

      2. Click the desired field to select it.

      3. Click OK.

      4. Type the desired value in the Value box or click Function to enter a formula.

        For more information regarding formulas, see Add functions and formulas.

    • Query for data

      • Click the appropriate receive data connection from the Data connection field or click Add to add a new data connection.

        For more information regarding data connections, see Data connections overview.

    • Submit data

      • Click the appropriate submit data connection from the Data connection field or click Add to add a new data connection.

        For more information regarding data connections, see Data connections overview.

    • Open a new form to fill out

      • Enter the template ID or the location of the form template in the Form Template ID or Location box, and then click OK.

    • Close the form

      • Click OK if this is a Web form or, if this is a Filler form, click the If changes have not been saved, prompt the user to save check box to prompt users to save the form before it is closed.

    • Send data to a Web Part

      1. Click Property Promotion to select the fields that should be promoted as Web part connection parameters.

      2. Next to the list of SharePoint Web part connection parameters, click Add to display the Select a Field or Group dialog box.

      3. Click the field.

      4. Enter a name for the parameter in the Parameter name box.

      5. Click OK.

      6. Repeat steps 2 through 5 to promote additional fields.

    • Sign signature line

      Note: Before adding a sign signature line rule, make sure that you have added a signature line control the form so that there is something for the rule to sign.

      1. Under Sign the first signature line where, in the list, click the method of indicating which signature line from the form should be signed.

      2. In the is equal to box, enter the criteria or click Function to use a function for the criteria.

      3. Indicate whether or not a default signature image should be used and whether or not the signature line is in the host document, and then click OK.

        For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.

  3. Click the Don’t run remaining rules if the condition of this rule is met check box if you want to stop processing additional rules after the selected rule is processed.

Setting parameters for querying or submitting data

The submit data and query for data actions activates the data connection to either send or receive data. In the case of query for data, you can specify what data is queried by adding a set a field’s value action rule to set the value of the desired query field.

Data entry patterns

Action rules can be based on the text pattern that a user enters into a text field. For example, if you want to collect a ZIP/Postal code, then you might want to make sure the user enters it in the correct format. Likewise, if you want a user to enter an email address, then you can match their input to a pattern that includes some text, an @ symbol, a domain, and a domain suffix such as .com.

To do this, when building the condition, in the Operator list, click Matches Pattern, then click Select a pattern. This displays the Data Entry Pattern dialog box where you can choose from several pre-defined, standard patterns. If none of these patterns meets your needs, you can use a custom pattern.

Advanced condition scenarios

The following are advanced scenarios that you can use when setting the condition of an action rule.

  • Base a rule on an expression

An expression is a set of values, fields or groups, functions, and operators. Use an expression to set the value of a field in such scenarios as automatically including the current date on a form, or adding the cost of items entered into an expense report to get the total.

  1. Click The expression.

  2. Enter the expression into the second box.

For more information regarding functions and formulas, see Add functions and formulas.

  • Base a rule on a set of signable data

If a form requires a digital signature, you might want to disable the submit button if the form has not been signed. Or, for example, you might want to activate the submit data action after a user adds a digital signature. This condition is only supported in InfoPath Filler forms.

  1. Click Select set of signable data.

  2. In the Select Set of Signable Data dialog box, click the set of signable data, and then click OK.

  3. Click the desired condition from the second box, and then click any necessary criteria from the third box.

For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.

  • Base a rule on a user’s role

If your form has multiple views, such as an administrator view and a read-only view, then you can create a form load rule that switches to a view based on the current user’s role.

  1. Click User’s current role.

  2. Click the operator, such as is equal to.

  3. Click the role or Manage roles to manage user roles.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×