Microsoft InfoPath 2010
The official blog of the Microsoft InfoPath team

Check if form is new using roles, not code

Check if form is new using roles, not code

  • Comments 2
Ever want to add conditional formatting or special rules that only fire if your form was just created?
 
For example, you want to show one view by default when someone creates a new expense report, but you want show a summary view for everyone else who opens the form.
 
Here's how.
 
Click on Tools, then User Roles, and use the dialog to add two roles:
  • New Form: Check the checkbox for "initiator" (don’t set any other properties) This role will apply for new forms only.
  • Old Form: Set this one as the "default" in this list
 
You'll get something like this in the dialog:
 
 
Now you've got roles to detect whether the user just created the form or is opening it later on, so you can use that information in Rules, Data Validation, Conditional Formatting, even Filters. Just go to the place you want to be conditional, then pick User's Current Role in the first dropdown of the condition, and pick the role you want to test for in the third dropdown (New Form or Old Form).
 
You'll get something like this:
 
 
Now when someone opens the form, you'll know if they just created it or are coming back later, and can make your form dynamic accordingly. It doesn't make sense for most forms, but like all the tricks in the blog, I hope this trick helps you make quick progress when the need arises.
 
And there you have it. A little tip for the week.
 
- Ned
Leave a Comment
  • Please add 1 and 2 and type the answer here:
  • Post
  • Will this work/conflict if I want to have a User role as the default that is assigned to a domain user group?
  • This could conflict, but you should be able to make it work by simply adding the domain user group to either "Old Form" or "New Form" above. In your case, since it will be the "default", you would want to add the domain to "Old Form".
Page 1 of 1 (2 items)