Using InfoPath Form Web Part to Display Existing Form (not a New One)

sh_kamalh picture sh_kamalh · Jun 13, 2011 · Viewed 10.9k times · Source

InfoPath form web part can be used to fill out a published InfoPath form (a new instance). I want to use the web part to open an already filled form to do some modifications. Can this be achieved (using this web part or any other solution)?

The reason behind this requirement is that I want to have multiple web parts in my page, content editor, query string filter and InfoPath web part. I want to use these to open a form (new or existing) in a certain mode / view.

Edit
I will try to simplify:
1- I have an InfoPath form that is saved in a SharePoint library. The form have multiple views.
2- Using a URL like http://mySite/myPage.aspx?form=myForm-20110613.xsn&view=View3, I want the form myForm-20110613.xsn to be opened and switched to View3.

How can I achieve this (preferably without writing any code)?

Answer

sh_kamalh picture sh_kamalh · Jun 19, 2012

I have done that using a custom application ASPX page. The page has an Iframe that I set its src to the viewing URL as follows

private void SetIFrameSource_View(HtmlControl frame, string libraryName, string formName)
{
    string formServerPage = "http://servername/_layouts/FormServer.aspx";
    string xmlLocation = string.Format("/{0}/{1}", libraryName, formName);
    string source = "http://servername/SitePages/Home.aspx";
    frame.Attributes["src"] = string.Format("{0}?XmlLocation={1}&Source={2}&DefaultItemOpen=1", formServerPage, xmlLocation, source);
}