Message Box in InfoPath 2010

Learn how to display and use message boxes in InfoPath 2010 by showing either static text or a message that is based on values within a form.

The display of message boxes in InfoPath 2010 is only supported in InfoPath Filler Forms.

This means that if you want to create an InfoPath form SharePoint 2010, you'll have to use some other means of showing messages to the user such as for example data validation, hidden sections, or calculated values.

You can display a message box in InfoPath 2010 when a user clicks a button or when the value of a field changes.

InfoPath 2010 offers two Actions you can add to Rules to display a message box:

  1. Show a message
  2. Show the value of a field or formula

The first Action is static, meaning that you'll have to type in the message you want to display at the time you create the InfoPath form template.

The second Action is dynamic, since the message you display is dependent on the contents of a field.

Display static text in a message box in InfoPath 2010

To display static text in a message box in InfoPath 2010 when a button is clicked:

  1. In InfoPath 2010 on the File tab, click New.
  2. Under Popular Form Templates, select Blank Form (InfoPath Filler) and click Design Form.
  3. On the Home tab under the Controls group, click Button to add a button control to the InfoPath form template.
  4. On the Home tab under the Rules group, click Add Rule, select When This Button is Clicked, and then select Show a Message from the menu.
  5. On the Rule Details dialog box, type in a message, for example 'Hello World' and click OK.
  6. On the Home tab, click Preview to preview and test your InfoPath form.

Now whenever you click the button a message box with the text "Hello World" will appear.

Display dynamic text in a message box in InfoPath 2010

To display dynamic text in a message box in InfoPath 2010 when a button is clicked:

  1. In InfoPath 2010 on the File tab, click New.
  2. Under Popular Form Templates, select Blank Form (InfoPath Filler) and click Design Form.
  3. On the Home tab under the Controls group, click Option Button.
  4. On the Insert Option Buttons dialog box, type 2 and click OK.
  5. Select the first option button, and then click the Properties tab.
  6. On the Properties tab under Properties, click Control Properties.
  7. On the Option Button Properties dialog box, type blue in the Value when selected field, select the This button is selected by default check box, and click OK.
  8. Select the second option button, and then click the Properties tab.
  9. On the Properties tab under Properties, click Control Properties.
  10. On the Option Button Properties dialog box, type green in the Value when selected field, and click OK.
  11. On the InfoPath form template, type blue behind the first option button, green behind the second option button, and then click below the second option button to place the cursor.
  12. On the Home tab under the Controls group, click Button to add a button control to the InfoPath form template.
  13. On the Home tab under the Rules group, click Add Rule, select When This Button is Clicked, and then select Show Field or Formula Value from the menu.
  14. On the Rule Details dialog box, click the function button behind the Expression text box.
  15. On the Insert Formula dialog box, click Insert Function.
  16. On the Insert Function dialog box, select the All category, and then select the concat function from the list, and click OK.
  17. On the Insert Formula dialog box, highlight the first double click to insert field text in the concat function, and type the text "You selected ".
  18. On the Insert Formula dialog box, double-click the second double click to insert field text in the concat function.
  19. On the Select a Field or Group dialog box, select field1, and click OK.
  20. On the Insert Formula dialog box, highlight and delete the third double click to insert field text in the concat function. Your final formula should look like the following:

    concat("You selected ", field1)
  21. Click Verify Formula.
  22. Click OK to close the message box, and then OK on the Insert Formula dialog box.
  23. On the Rule Details dialog box, click OK.

    Show the value of a field or formula Rule for a message box in InfoPath 2010

    Figure 1. 'Show the value of a field or formula' Rule for a message box in InfoPath 2010.

  24. On the Home tab, click Preview to preview and test your InfoPath form.

Now whenever you select either blue or green and then click the button, a message box with the text 'You selected blue' or 'You selected green' should appear.

Form in InfoPath 2010 displaying a message box with a dynamic text

Figure 2. Form in InfoPath 2010 displaying a message box with a dynamic text.

With this you've made the text that is displayed in a message box in InfoPath 2010 dynamic. You can use this technique to display the value of any visible or hidden field on an InfoPath form in a message box.

 
 Subscribe for updates via RSS or Email

Related InfoPath Articles:





InfoPath 2013 Cookbook: 121 Codeless Recipes for Beginners

InfoPath 2013 Cookbook 2: 121 Codeless Recipes for SharePoint 2013

InfoPath 2010 Cookbook: 101 Codeless Recipes for Beginners

InfoPath 2010 Cookbook 2: 101 Codeless Recipes for SharePoint 2010

InfoPath 2010 Cookbook 3: 101 Code Recipes for C# Developers

InfoPath 2010 Cookbook 4: 101 Code Recipes for VB Developers

InfoPath 2010 Cookbook 5: Integrating InfoPath with Excel and Excel Services