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!

33 comments

  • 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…

    Like

  • Laura, that’s brilliant. Many MVPs ignore this and claim as impossible when asked at conferences. Thanks for sharing

    Like

  • Sue, Are you working with a form library form? This solution won’t work with a sharepoint list form.

    Like

  • 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?

    Like

  • 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.

    Like

  • 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

    Like

  • 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!

    Like

  • 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. 😉

    Like

  • 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!

    Like

  • 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

    Like

  • James,
    Sorry, this is a known bug.

    Like

  • Hey Laura,

    You say this solution won’t work with a list…can you tell me how to accomplish this in a list please?

    Bhank you!

    Like

  • Laura,
    Was wondering if I could create a column called Print then put the link to the specific view in that column so when a user selected a document and then clicked on the hyperlink, they could print the specific view?

    Like

  • Beth,
    Sorry it can’t be done with a list form. List forms are so limited, which is why I pretty much stick with only Form Library forms.

    Corrie,
    That would be really nice, but this solution only works with a new form, and not an already existing one.

    Like

  • I’m just posting a comment because I found this post helped me. I was able to use the tip you provided with an Infopath based List Form (SharePoint 2010). I don’t use Form library’s as I just tend to customize a List Form using Infopath 2010 to make it fit my needs and sometime just to make it look nicer than the default list forms.

    Here is a working example of my link that goes directly to a view on my form, specifically the New Employee Training View. This form has a grand total of 7 views so I’ve been really looking for this type of capability:

    http://portal/HR/Lists/NewEmp/Item/editifs.aspx?List=75b84bc7-3b62-4a87-87b9-6996a90540d1&ID=40&DefaultView=New%20Employee%20Training&Source=http://portal/HR

    Thank you so much for finding this and I hope this helps someone else

    Like

  • Good day.
    I wonder if this solution is to use the Edit instead of Edit form

    Like

  • Dear Robin,
    Your solution for SharePoint 2010 list forms are perfect!
    I was searching for it for a long time!!

    THANK YOU!

    Like

  • I have two image buttons on a webpart page. I also have a published form to a form library in sharepoint 2010. The form has 3 views (View 1, ProjectRequest, and ProductProjectRequest). I would like the form to be created using the ProjectRequest view when one image button is clicked on and a and the ProductProjectRequest when the second image is clicked on. I am trying to use the &DefaultView=ProjectRequest for one link and &DefaultView=ProductProject request for the other. But the form keeps openning to View 1. Can someone assist me? Is this possible?

    Like

  • Julio,
    You can use the InfoPath form web part on any page, and in the web part settings you can specify which view it needs to show. Then you have to put the form library as a web part on the same page and create a web part connection to send form to the form web part. That way, when you click on a form in the library, it shows that form in the form web part, on the specific view you want.
    Kevin,
    I’m not sure what’s going wrong, try not using any spaces in the view names?

    Like

  • I cannot get a 2010 filler form to open to a specific view via the &DefaultView portion of query string, similar to Kevin on 11/13/14.
    And yes, I did spell view name correctly. Also, the DevaultItemOpen parameter does not make any difference no matter how I set it in the URL. The two web parts on a page and query string trick doesn’t work cause my installation of forms serves does not support browser based forms.

    any ideas how to force filler to open to a view?

    Like

  • Dick,
    This doesn’t work for filler forms. My advice: don’t use filler forms.

    Like

  • Hi Laura,
    I can’t get this to work. It may be because my form link is more complex because I added JS to get it to open in Modal. Why is this not working?

    ​Client Complaint Centre Click here to create a new complaint.

    Like

  • Laura,

    Great stuff as usual! I have an issue that is somewhat related to this and was wondering if you have any pointers.

    I have a couple of different views that open for a specific list(depending on the task). The view navigation is working perfectly, however, I have a security issue when the user is on those views. The main list link is still displaying above the form webpart in each of these views. If the user clicks this link, it will take them to the main list. I do not want to allow users to be ablet o navigate to the main list. Do you have any idea how I can remove this link?

    Thank you very much!
    Mike

    Like

  • Hi David,
    Sorry, but I don’t know anything about JavaScript. All of the forms that I’ve done this with are no-code.
    Mike,
    I recommend deleting that default view if you don’t want them to be able to go to it, or make it so that it filters down to nothing. Like Title is equal to “monkey” or something.

    Like

  • Thanks Laura! That is the path I was heading down. Is there a way to set audience targeting on a view? I still have some users that will need to access this data.

    Thanks!
    Mike

    Like

  • Mike,
    No, there is not a way to set audience targeting to a view. You’d have to pull in information about the currently logged in person using either the user information list or the userprofileservice (that I’ve blogged about before), and then you’d have to create a rule that would show or hide something or switch a view according to some property of that user, such as if they’re in a certain department or have a certain job title. Or you could create a sharepoint list and just put a people field and a list of people in it. Have your form do a data connection to that list, and then the rules in that form would have to look to see if CurrentUser() is in that list.
    Unfortunately, all of these are fairly complex, and not as simple as “set a target audience”.

    Like

  • Is there any way I can Disable View Form based on user permission?
    Also is there any way i can share a link of any of the SharePoint records to open a form with specific view enabled or active when load form?

    As I am new to InfoPath please revert back in case need to understand above questions.

    Like

  • Laura,

    I’m following this exactly. It has worked before but now it does not. I created a second view in IP and drag and dropped controls from the first (default) view. However, when I follow the article and do exactly the same it does something weird. When the link is clicked the second view opens but the controls are not populated with the values a user selects from the first view. Can you tell me why controls aren’t populating in second view? Twiiter handle @heatguy1986

    Like

  • Thanks for the post but is there a way to open the hyperlink in the same window rather than the default new window?

    Like

  • Kalpesh,
    No, there are no permissions based views, but other ways to simulate it with rules to hide or show buttons.
    You’d use form load rules inside the form in order to make an existing form go to a certain view when you open it.

    Jake,
    This is only for a brand new form being filled out. If the user is already in the form and you need to switch them to another view, use a button and put a rule on it to switch views.

    Sharon,
    No, I have not found a way to do that.

    Like

  • I don’t understand when you say it only works with new forms. I have an existing form where I created a new view. I followed the directions but it opened the default view of the form. I am also trying to find a way to open the item in the new view with a link from a workflow. Would you happen to have a way to do that?

    Like

  • If you’re using sharepoint online and InfoPath 2013/2016, you can link by just adding “&DefaultView=XXXX” at the end of the URL. Where XXXX is the name of the view

    Like

Leave a reply or question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s