in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Toth’s Tales from the Trenches

Practical SharePoint experience articles, tips, and frustrated rants and ravings.

September 2008 - Posts

  • Switch Views when InfoPath Form is Opened

    I designed a form for a client that had several different views, and I needed a way to display a specific view when the form was opened. This was easy, but took me a bit to figure out.

    1. Go to Tools > Form Options.
    2. Click the Open and Save option.
    3. Click the Rules button, and add rules and actions to switch views.

    With this method, I was able to set a field on form submittal to indicate which view was last active. When the submitted form was re-opened, I was able to use a conditional rule to switch to that last active view.

  • Make InfoPath Contact Selector Required in Browser-Enabled Forms

    If you've used the InfoPath Contact Selector before, you might have seen that it does not support validation like other InfoPath controls do. There is no option on the Properties dialog for the control to make it a required field. To work around this, I used a combination of rules and conditional formatting to prevent the form from being submitted if the control does not have a value.

    The easiest way to do this is to create conditional rules in the Submit Options dialog:

    1. Configure your form and add a Contact Selector control (see this article for instructions).
    2. Go to Tools > Submit Options.
    3. Make sure that Allow Users to Submit this Form is checked.
    4. Click the option to Perform custom action using rules.
    5. Click the Rules... button.
    6. In the Rules dialog, click the Add... button.
    7. In the Rule dialog, click the Set Condition... button.
    8. In the Condition dialog, pull down the first dropdown, choose Select a field or group..., and drill down and choose the DisplayName field from your data connection. Select is blank in the second dropdown.
    9. Click the And> button to add a second condition.
    10. In the last dropdown on the first condition, change it from And to Or.
    11. In the second condition, select the DisplayName field again, and choose is not present for the condition. Your two conditions should look like this:



    12. Click OK. In the Rule dialog, do not add any Actions. Check the box to Stop processing rules when this rule finishes.
    13. Make sure that this rule appears first in the list of Rules.

    The only downside to this approach is that there is no visual to the user, since InfoPath Forms Services does not support showing a dialog message. The form will just not do anything. To get an even better user experience, You can hide the Submit option from the Toolbar, and use your own Submit buttons with Conditional Formatting:

    1. Drag a button on the page.
    2. Right-click and choose Conditional Formatting....
    3. Click Add... to add conditions.
    4. In the Condition dialog, add the two conditions in steps 8-11 above, and choose Disable this Control.


    Now, your submit button will be disabled until the user picks a person.


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts