This is part of a series of posts about some InfoPath tips and tricks. It’s not an introductory tutorial and will assume that you have some knowledge of InfoPath. All solutions will use InfoPath 2010 with SharePoint 2010.
A really useful feature in InfoPath is the ability to create multiple views within a single form. These can be used for two key benefits:
- Display a different view when the form is opened – useful for automating processes e.g. after a new form has been submitted, a reviewer opens the same form but sees a Reviewers view with different fields available to edit.
- Break a form into smaller chunks by switching views whilst the form is open – useful for easier viewing amongst other things…
Create a new view
With a form open in InfoPath 2010 Designer, click on the Page Design tab in the menu. On the left of the menu is a Views section. Here you can set the properties for the current view, delete it and create a New View. (Page Setup just opens the Properties with the Page Setup tab instead of the General tab).
If you want to create a new view, click New View…
Within Properties for the current view, there are some useful settings worth considering.
On the General tab, a box is checked ‘Show on the View menu when filling out this form’. If you want to control what view a person can see during the process (e.g. when filling out a new form, you don’t want people to also complete the Reviewer’s section) then uncheck this box. If it is checked, it will be visible in a dropdown menu (unless the View menu itself is disabled – more on that in a separate post).
Under Print Settings, you can control which view appears when a user goes to print the form. This is a great little feature. Create a dedicated ‘Print’ view, and then for all other views, configure the Print Settings to open the Print view. For the Print view itself, under General set it to be Read-only.
Finally, make sure you pick carefully which form is to be the default view. In the absence of any criteria saying otherwise, this will be the view that opens. In most cases, this should be the ‘New Form’ view, since it will be the view that opens when someone goes to create a new form.
Display a different view when the form is opened
You should want the ‘new form’ view to be displayed when a new form is created. But once it has been saved and submitted to a library in SharePoint, you may want a different view to then be displayed for editing or for specific stages of a process.
To do this, you need a criteria to determine what stage the form is at. I tend to use a ‘formStatus’ field that is updated based on what the user does with the form. The value of the formStatus field then determines which view is opened. Here’s how:
Step 1: Create and manage a formStatus field
Create a field called formStatus, of data type Text (note: this field doesn’t need to be added to the form, it can be created direct in the Fields list). Set the default value for the field as New.
Add a Button control to your page. For its properties, make the label ‘Submit…’ (or similar), leave the Action set to Rules and Custom Code and click OK.
Single click on the button and the Rules taskpane should appear on the right of the page. If it doesn’t, in the Home menu, click on Manage Rules (you must have the button selected to create a rule for it).
- In the Rules task pane, click New and select Action
- Give the rule a title (Details), e.g. ‘Update Form Status to Submitted’
- You don’t need to set a condition, the rule will run when the button is clicked
- Next to actions, click Add and select ‘Set a field’s value’
- In the Rule Details dialogue box, for the field, select your formStatus field, and for the value, type ‘Submitted’ and click OK
Now, when a user creates a new form, it will start with a formStatus of New. When the user clicks to submit the form, the formStatus will be updated to Submitted.
Step 2: Configure the form to switch views when it is opened
We can now control which view of a form is opened based on the formStatus field. Note: this requires having at least two views already configured, for example: New Form (Default) and Review Form with additional fields for a reviewer to complete.
In InfoPath, click on the Data tab to display the Data Menu. To the far right of the menu is a section called Rules. Click on Form Load. This is a special rule for controlling what happens when the form is opened (or ‘loaded’ into memory, hence the geeky label).
- In the Rules task pane, make sure the title shows as Form Load. Click the New button and select Action (its the only option available to use)
- Provide a title (Details for) the rule, call it something like ‘Open Review View for Submitted forms’
- Set the condition to be where formStatus is equal to Subitted.
- Next to Run these actions, click Add and select Switch views.
- In the Rule Details dialogue box, select the view you want to be opened when the formStatus is Submitted. Click OK
In the image above, you can see the rules I have created for the Form Load. For completeness, I recommend creating a rule to open the New Form view. Yes this will be opened by default, but I like to cover all possibilities. As long as you manage that formStatus field, you can be certain which form view will open at any time during the process.
Switch views whilst the form is still open
As well as controlling which view is displayed when the form is opened, we can switch views whilst still in the form. This is recommended if you have a large form – break it into chunks. You can do more than just switch views at each stage…
If you choose to have the views displayed in the View menu, the user can pick any view at any time. You might not want to let them do that. A more manageable method is to make switching views part of filling out the form. At the end of each view, add a button to proceed to the next view (and go back to the previous one if you want to).
Step 1: Add a button to your form
On the Home menu, in the Controls box add a Button control or, if you want to make it even more obvious, add a Picture Button control and use arrows instead.
In the image above, I have added a Picture Button control and selected my home made Arrow picture. See end of the post for a tip on creating your own.
Step 2: Add a rule for when the button (or Picture button) is clicked
Make sure your button is selected (has the square handles displayed around it) and open the Rules taskpane if it isn’t currently showing (on the Home menu, click Manage Rules)
In the Rules taskpane
- Click the New button and select Action
- Provide a title (Details for) and give is a useful name, e.g. Switch to View 2
- You don’t need to set a condition, you want this rule to run whenever the button is clicked.
- Next to Run these actions, click Add and select Switch Views
- In the Rule Details dialogue box, select the view you want to switch to and click OK
And hey presto, we can now switch views as part of completing the form. The image belows shows my form in Design mode with the rule configured.
—
How to create that arrow? If you want a simple DIY cheat to create images for Picture buttons, open PowerPoint. Within PowerPoint, create the image you want. Then right click and choose Save as Picture…
In the image above, in PowerPoint I simply inserted an arrow from the Shapes available in the Insert menu (Illustrations section), added a bit of text, removed the chunky line around it, then right-clicked and saved as a picture. Then in InfoPath, open the properties of your Picture button and select your image.
And that’s all for now. Some tips for using views in forms.
All good forms should have more than one view. As a simple rule of thumb, if you only need one view, you don’t need a Forms library, you should just use a standard SharePoint list and modify the form that comes with the list (it’s a ready-made InfoPath form) which is far quicker and easier to do.
Click Here to view other InfoPath posts in this series.










Absolutely fantastic tutorial Sharon! Any chance you could do a guide on restricting what a user can see on a form based on their user account or group membership? Please!
Richard
Hi Richard
Thanks so much – positive feedback always helps keep the blog posts coming
What you’re asking for is heading into advanced territory for SharePoint and InfoPath – in essence, a compound document. That’s the domain of Documentum and the likes. It’s technically becoming possible with SharePoint, InfoPath and Office thanks XML file formats but is still a way from being easy to implement.
In short, let’s see what the next version brings. The hacks to make it work currently are unlikely to be acceptable for what you need.
good one. how to handle the case where reviewer should be able to view all fields submitted as read only but have his additional fields which he can edit?
Hi Kartik
In your reviewer view, just add in the additional fields (i.e. don’t include them in the original new form view). e.g. if it were an appraisal, you might want a field ‘manager’s feedback’ – you add that field to the manager view. (And use workflow to set permissions so that even if a non-manager opens the form, only the manager can make edits)
Hope that helps.
I’m trying to put in a button of some type to allow a user to go from a view only view to the edit view, but the buttons either don’t appear on the form at all or are not clickable. Any ideas?
Thanks for this great post Sharon! I have a question about the print settings for a view – are they only valid for printing from InfoPath? I’ve set mine to print just the first page, but when I print from the browser form (which is what everyone will use) it’s ignoring all the settings I’ve configured for the print view.
Hi Monica
Thanks for the feedback!
Not sure what’s misbehaving. When I’ve set the print view it follows through when printing from browser as well as InfoPath Form Filler. One other way to force is to make the print view the only one visible in the browser, so it will appear on the ribbon menu… Hope that helps.
Hi Sharon,
This is really great and helped me out alot, you rock!
One question, how do i redirect users upon clicking ‘submit’ to home page, rather then taking the users back to the list view?
Many thanks in advance,
Regards
V
Hey Vimal
Cheers as always
This one is easy. In the link to open the form, you just need to add a Source reference. Then when the user clicks submit, they’ll be sent to the URL in the source. e.g. if you wanted the user to be sent to a thankyou page, you would add to the link ‘&Source=http://site/pages/thanks.aspx’ for example.
Shout if you’re not sure – I’ll do a full post with a demo to help explain in more detail.
All the best
S.
Hi Sharon,
Great job, i’m using Sharepoint Designer & Infopath 2010 on a sharepoint online solution.
I had experienced multiple view with for multiple users, however they must have read, write and “delete” access on the documents list !
Do you know how can we forbid / prevent a user to delete a document he didn’t create ?
With the online version, i needed to create custom list with users permission, because we can’t use webservices to read UserGroups.
Did you experience sharepoint online ?
Hi Marc
Thanks
For what you’re after, it’s not easy with SharePoint Online because you don’t get such granular options to control settings.
But what’s the problem with deleting? Items can always be recovered from the Recycle Bin if they were deleted in error, and an alert could be configured to keep track of if/when that happens… would that suffice?
All the best
Sharon.
Sharon, can’t thank you enough. I was about to throw InfoPath out alltogether because I couldn’t figure out how to add and edit with different forms, uh, views. Brilliant now!
Thanks bluewater, feedback like that makes blog posts worth writing. Good luck with your projects!
Can we read the data from View 2 in View 1 or vice versa?
Hi Shubha
Yes – provided the fields have been created and contain information, they can be displayed (read only or editable) on any view.
Dear Sharon, first of all thank u so much for excellent post. But I m facing a little bit or problem more.
After creating customized InfoPath 2010 Views and Published them everything is working fine. but in the browser title I am not getting the usual browser title.
Usually it is “list name – item name”. But I am getting only “list name – ” . So Please help me. Please…..
Hi MK
Thanks for the feedback. Can’t help with your question off the top of my head though I’m afraid. Or rather, I’d have to resort to Google to remember what the different options are for controlling what gets displayed in the browser headers. The answer will be out there somewhere. I’ve never taken much notice of them in SharePoint. The easiest place to start would be to crack open the default list item template and see what’s in there, then see if you can apply it to the custom InfoPath template. Should be doable…
Hi Sharon,
Great Article!
When I created the form, I also created a view, so I have the default view (Location) and a second view (Project). I followed your steps and added the next button. When I run the form and click next, the project form appears beneath the Location. How do I get the “Location” to dissapear or hide it?
Also, how do I implement the back/previous button?
Thanks for any help you can provide.
Hi Isaac
Thanks!
Provided the two views are completely separate, they won’t appear together on the same page. Check in case you did a copy to create the second view and left the original as part of it. I’ve done that before.
To do back | previous depends on exactly what you want. If you have a series of views that should be display in sequential order, it’s easy – use back/previous to move to the previous view in the sequence… you need to configure it per view.
…but… if you mean back/previous as in mimicking the browser, that’s a lot trickier and would involve coding. Not my forte I’m afraid.
Hope that helps.
Hi Sharon,
Thank you much!
This has been a great help
If I have two views, the first one used to allow the user to enter data and the second one to just view (read only) when the item has been entered…how do I edit an item easily if the user made a mistake when originally creating the item? I’m asking b/c we want to maintain the items entered with a single user (administrator) that will be the only one who has the rights to edit items after they have been submitted.
Thanks for any advise you might have!
Hi Thomas
Thanks for the feedback
If the only difference between the two views is to be able to edit data versus read-only, an alternative option would be to stick with one view and manage permissions through workflow.
To do this:
- set the default permissions for everyone to Contribute so that they can create new forms, use a Windows or SharePoint group to identify, e.g. Authors
- use a Windows or SharePoint Group to identify Reviewers (even if there is only one)
- create a workflow to be triggered when an item is created – update the item permissions so that the Reviewers Group has Contribute permission and the Authors group has read-only (or, if you only want the Reviewers and the original author to see the item, set the permissions so that CreatedBy user now has read-only
One word of caution when using individual item permissions – they don’t scale well (i.e. avoid large lists) so make sure you also include some kind of expiry/deletion policy through Retention settings to prevent the list growing to a size that impacts performance.
Hope that helps. If it sounds about right but you want more details, let me know and I’ll try and make a separate blog post to walk through it.
Hi, I have a similar problem to Lisa whereby the correct form opens but view that appears is Read-Only and the Submit button i’ve added doesn’t even appear (i have full permission to the list, and the form is not “read-only” in the Properties). Any ideas?
Fantastic. Thank you so much
Hi Tom
Not easy to say without looking at it. Permissions would have been the first thing I’d check and sounds like you’ve already done that.
Try testing the form from within InfoPath to make sure that the triggers to control what view is displayed when the form is opened are correctly set.
Hi,
great post! I have learned a lot from it. However (and isn’t there nearly always one..) I have a customised SP2010 List form with Add and Edit views which allow user to update info as well as two read-only views which are used to produce a printout in association with some CSS to hide other web page elements when printing (one is a certificate for local court to show a participant has attended/completed a court mandated traffic offender program and the other is a certificate for folks who attended just because they wanted to be better drivers).
I have placed buttons on the Edit view to the two read only views and set rules to 1) submit data then 2) switch view. My problem is that after updating some info on the Edit view and clicking either of these buttons, the updates aren’t showing (i.e. the data is as it was when the form was initially loaded). How can I force the view to reflect all the current information so that I don’t have to have the user save/close the form and then re open it just to get up to date information on the read only print views?
Any tips would be greatly appreciated, this has been driving me nuts for days and all my Googling and delving in to my InfoPath books has come to nought…
Hi Mark
Are you using a customised form for a list rather than a form template attached to a forms library? If so, this may be a little trickier to solve.
There are a couple of hacks you can try. (Haven’t tested so let me know how they go).
1. Try getting the form to reload its data after the submit by adding a rule to retrieve the data again (may need a second retrieve data connection to convince SharePoint it needs doing – it would definitely prefer you to close and reopen)
2. Play around with how you use fields on the form (this would be a lot easier if it were a forms library…). When the user edits the fields, use a rule to copy the values into separate ‘dummy’ fields within the form. Display the dummy fields on the print views. They should display the changed values rather than the originals.
Give it a try and let me know if you get the results you wanted. If I get a chance over the next week, I’ll have a tinker myself. I’ve only ever used multiple views on forms libraries, not standard lists.
Hi, Sharon,
I really liked your info. I noticed that some have asked how to make the views change depending on the users permissions. While a workflow can be constructed, many users do not have access to SharePoint Designer. I think I have found a simple way to create permissions that switch views using InfoPath with SharePoint. It also has the advantage of allowing the form administrator or person responcible for the form to add or remove permissions without having to open the form in Infopath Designer – that way the form creator is not bugged every time a name needs to be changed or deleted. I can email you the method and you can do the posting. I’ve searched the web for weeks and have not seen this way, but much more complicated ways instead.
Sharon, Is there a way to have the form switch views if the end user checks a box rather than clicks a button? I noticed under Run these actions that Switch Views is not an option when you use a check box instead of a button control.
I basically want the form to switch to an additional form view if a box is checked. (i.e. if new hire is a non-employee and Non-Employee box is checked, open the Non-Disclosure Agreement view to complete the required NDA form), then they can click a button to return to their original form and finish filling it out.
Hi Mel
When it comes to triggering views to appear, it is often better to stick with buttons to avoid confusion. Check boxes can be toggled on and off as we change our minds but to click a button is to expect something to happen.
Why not still include the button. Design the form so that the button is next to the box with a note to remind that an NDA form must be completed for non-employees. You can set the rules to check that the box has been checked before opening the view. If not, display a message – NDA not required. Then, for the next stage of the form (or submission), don’t let the user proceed if the box has been checked and the NDA not completed.
It’s a bit more design work to set-up but should be more user-friendly to complete.
Hope that makes sense.
Hi Tom
Thanks for the offer. The post was really about how to use multiple views to break down a form into simple steps. I don’t want to complicate it with tinkering with user permissions. If you post the solution somewhere, let me know and if it adds to this scenario, I’ll drop a reference link in the post.
Sharon -
Thank you!! I was completely at a loss why I couldn’t figure out how to have different “display” forms vs. the edit form. It seemed like it should be something easy – THANK YOU for posting this solution. Exactly what I needed!
You have won a virtual kewpie doll.
Hi Eric – not sure I dare ask what one of those is
but many thanks for the kind feedback