Skip Ribbon Commands
Skip to main content

Laura Rogers @WonderLaura

:

Quick Launch

Laura Rogers @WonderLaura > Posts > Link to a Specific InfoPath View
Hi everyone,
My blog now has a new URL!
You can now find me at http://www.wonderlaura.com
October 04
Link to a Specific InfoPath View

In many cases in InfoPath, especially when testing, it is helpful to be able to click to go directly to a specific view of a form.  Of course, you can always insert a button in a form whose action is to switch views, and use a formatting rule to only show that button to certain people.  This is what I’ve been doing for years, but in this blog post I’m going to show you a different trick that lets you create a hyperlink directly to a specific view of in a form. 

It is a query string parameter, and the syntax is:

DefaultView=ViewName

When you click to create a new browser-based form, here is an example of the URL you will see in the address bar:

http://portal.contoso.com/demo/_layouts/FormServer.aspx?XsnLocation=http://portal.contoso.com/demo/CheckReqest/Forms/template.xsn&SaveLocation=http%3A%2F%2Fportal%2Econtoso%2Ecom%2Fdemo%2FCheckRequest&ClientInstalled=true&Source=http%3A%2F%2Fportal%2Econtoso%2Ecom%2Fdemo%2FCheckRequest%2FForms%2FAllItems%2Easpx&DefaultItemOpen=1

Normally, when formulating a link to a form, I’ll take the above and trim it down a bit. 

  • I usually only include a submit button in the form and not a save button, so &SaveLocation isn’t needed. 
  • Also, I usually change the &Source to take you back to the main page after filling out the form.  In this case, the site I want to be redirected back to is http://portal.contoso.com/demo.
  • I’ve found that when I keep it browser-based, the &ClientInstalled isn’t needed.so the URL is:

http://portal.contoso.com/demo/_layouts/FormServer.aspx?XsnLocation=http://portal.contoso.com/demo/CheckReqest/Forms/template.xsn&Source=/demo&DefaultItemOpen=1

In a lot of cases when testing a new form, I’ll create a view called ADMIN, and just dump all the form’s fields on it.  This way, I can troubleshoot any validation errors, rules, etc.  Here is how to formulate the hyperlink to open a new form directly this ADMIN view.  Note that this DefaultView parameter only works with a new form, and not on already existing ones.

http://portal.contoso.com/demo/_layouts/FormServer.aspx?XsnLocation=http://portal.contoso.com/demo/CheckReqest/Forms/template.xsn&Source=/demo&DefaultView=ADMIN&DefaultItemOpen=1

It doesn’t appear to work when you put it at the very end of the URL, so it needs to go before the DefaultItemOpen.  So now that you know what the syntax is, I’ll tell you about another example of a case in which I’ve used it.

I have a view in an expense form that is the most commonly used view.  Then, I have another view that’s not the default, that’s called “New”, and it is a very trimmed down view with only a handful of fields that the initiator can fill out.  Once the initiator has filled out some basics, this form goes through a workflow and approval process, and the initiator is not privy to that whole process.  In this case, I created a big pretty button on the homepage for “New Expense Report” and used the hyperlink (that last example above), with the default view being set to the New view.  They fill it out and are immediately redirected to the homepage.  People love pretty buttons.  I just use the Content Editor web part for this:

MA14SP-3

More Info:  I’ve written a couple of blog posts that are related to this topic:

May the &Source Be With You

SharePoint URL Basics

Buy my InfoPath book!

 

Comments

Sue

This isn't working for me at all, when I add the &DefaultView= to my url it still takes me to the regular default view and the form doesn't open...
Shane YoungNo presence information on 12/6/2011 11:10 AM

Alexey

Laura, that's brilliant. Many MVPs ignore this and claim as impossible when asked at conferences. Thanks for sharing
Shane YoungNo presence information on 12/18/2011 2:26 PM

Laura

Sue, Are you working with a form library form?  This solution won't work with a sharepoint list form.
Laura RogersNo presence information on 12/19/2011 9:58 AM

Matteo

Hi, I found your posts very inspirational.. I'm looking for a way to pass a querystring value to a form usgin formserver.aspx... Is there a way to do this?
Shane YoungNo presence information on 1/3/2012 5:13 PM

Laura

Matteo, Here's how you pass a query string value to an infopath form: 1. In the form, go through the publishing wizard and pick the correct field in the "parameters" section.   2. Put the infopath form web part and the query string filter web part on the same page. 3. Create a web part connection that sends the query string value to the parameter in the form.
Laura RogersNo presence information on 1/7/2012 6:45 PM

Darren Lowe

Hi Laura, I'm working through the examples in you InfoPath 2010 book (which is great BTW).  I'm wondering why certain forms appear to open in modal dialogs and other do not? The ones that do not open in a dialog are the ones associated with "forms" libraries. Is this by design?  I have confirmed advanced list settings in the browser and setting in InfoPath 2010 are their defaults.  Thanks for your wonderful book and your contributions to the community.  Thanks Darren
Shane YoungNo presence information on 1/9/2012 1:45 PM

Larry Weideman

Laura, if you were here I'd hug you. I searched to the edges of Google-ville trying to find this exact answer! I tried many things (including using a query string web part) but none of them worked.

Thanks you!
 on 2/22/2012 9:58 AM

Laura

Darren,
You're exactly right.  SharePoint list forms open in a modal dialog box, and form library forms do not.  That is just out of box behavior.  I'm not sure if there's a way to get around it, though, it may require code or javascript.

Larry,
I felt the same way when I found out about this solution.  ;-)
lauraNo presence information on 2/24/2012 11:17 AM

Gareth

Great stuff Laura thank you.  I may well become the latest purchaser of one of your books on the basis of this lovely nugget of info!
 on 3/17/2012 6:01 AM

James 

Hi Laura, 

I created a form with 3 different views (this is a browser-based form).  Users have to click the "Next" button to move on to the next view and fill it out.  When the user clicks the "Next" button, the correct view appears, but it shows the bottom of the view.  They can scroll back up to the top of the view to complete it, but it would be helpful if the view showed up at the top of the page instead of at the bottom. 

Is there a way to make the top part of the view show up when the "Next" button is clicked?  I looked online and found quite a few others with this same problem, but haven't been able to find a solution to it.  Any help would be appreciated. 

Thank you, 

James 
 on 6/12/2012 11:19 AM

Laura

James,
Sorry, this is a known bug.
lauraNo presence information on 6/13/2012 11:05 PM
​I have disabled any new comments on this, because my blog has moved to a new site.  Please go here: http://www.wonderlaura.com
RSS FeedFacebookYouTube
 

 Our Books for End Users