InfoPath – how to redirect the URL after the form is submitted

It is – just add the Source= parameter to the end of the URL, and that will be the page that will be opened when the form is closed.
Like this:http://vm-devmoss01:99/finance/Invoices/986.xml?&Source=http://vm-devmoss01:99/finance/Pages/approvals.aspx&OpenIn=Browser

How to: Use Query Parameters to Invoke Browser-Enabled InfoPath Forms

There are four methods for invoking an InfoPath form or a browser-based version of the form on a server running InfoPath Forms Services. These methods consist of URLs that reference a form template file (.xsn), URLs that reference a form file (.xml) based on a form template, URLs that reference the built-in FormServer.aspx Web page, and those that contain a reference to a custom page containing theXmlFormView control. The first three types of URL support using query parameters to control aspects of the resulting form, including whether it will be opened in the InfoPath client or rendered in the browser, the location where the form will be saved, and the Web page that the user will be directed to when they close the form.
By default, InfoPath forms will open in InfoPath even if a browser-enabled form is available. If InfoPath is not installed, the form will open in the browser. In addition to using query parameters to control how forms are opened, SharePoint library settings are used to control where forms are opened. To always force the form to open in the browser, choose Display as a Web page on the library’s Advanced Settings page.
There are nine different parameters that can be used for opening InfoPath forms. Some parameters override others or cannot be used together, as noted in the table below. Name/value pairs other than those listed in the following table are interpreted as Input Parameters and passed to the form. Input parameters consist of one or more name/value pairs separated by the ampersand (&) character that are specified when a form template is opened from the command line or a batch file using the/InputParameters command-line option, or when a form template is opened from a URL. For more information about using input parameters, see theInputParameters property of theLoadingEventArgs class.

Parameter NameDescriptionAllowed Values
Used to open an existing form. TheXmlLocation andXsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.
A valid URL to a form file (.xml) in the same site collection.
Used to open a new form based on a form template. If anXsnLocation is specified in a URL using FormServer.aspx, aSaveLocation should also be specified if the Save and Save As buttons need to be displayed. TheSource parameter should also be specified or the message “”The form has been closed”” will appear when the user closes the form. TheXmlLocation andXsnLocation properties are mutually exclusive; specifying values for both parameters will result in an error.
A valid URL to a form template file (.xsn) published on the same site collection.
If aSource query parameter is specified, the default value isBrowser.
IfXmlLocation is specified, the default value is the setting used in the library.
If onlyXsnLocation is specified, the default value isPreferClient.
IfMobile is specified, the form will be redirected to the MobileFormServer.aspx page for rendering. The form template must be enabled for mobile support or an error message will be returned.
The location to which the user will be redirected when the form is closed. The URL must be in the same site collection or an error will be returned.
A valid URL in the same site collection as the form.
DisableSave is the only allowed value. It hides the Save and Save As buttons and disables saving the form when it is rendered in the browser.
A Save As dialog box is displayed prompting the user for a filename, and then it is saved in the specified folder. An error is returned if the specified folder does not exist.
Any valid folder location on the site collection.
Does not redirect to FormServer.aspx for client detection or rendering in the browser. Default value is false. If true and anXmlLocation orXsnLocation is specified, a File Download dialog is displayed when using Internet Explorer.
false (default)
TheOpenIn parameter should be used instead, and overrides theDefaultItemOpen parameter value. A value of0 indicates that the request is from a document library and the InfoPath client was not detected. A value of1 indicates that the request is from a document or form library that has the Display as a Web page setting.
The query parameters and their associated values are not case-sensitive, but the corresponding properties of the XmlFormView control, such as theOptions andSaveLocation properties, are case-sensitive.Procedures

The following procedures require a site collection that you can publish form templates to, and the ability to create new sites in the site collection.
Placeholder values are used in the example URLs below. These values represent the following SharePoint and InfoPath items:
ServerName: A server running InfoPath Forms Services.
SiteCollection: The top-level site in a site collection.
FormLibrary: A form library or document library containing a browser-enabled form template.
Form1.xml: A form based on the template.xsn in FormLibrary.
NewFolder: A folder within the FormLibrary.
NewSite: A site within the SiteCollection.
The~sitecollection value used in the following URLs is not a placeholder value. It is a special token used with InfoPath Forms Services that enables relative links and site collection-scoped URL addresses.Using a URL with the XmlLocation parameter

Create a form template and upload it to a new form library.
Create a form based on that form template and save it as “”Form1″” in the library.
Enter the following URL, inserting actual values for the placeholder values:


Publishing administrator approved form templates

A. Steps at client-side (for InfoPath developers)
1. Create an InfoPath form and use managed code (C#) as business logic.The business logic needs full trust on the server to run.
2. Save your form and publish it to a SharePoint Server with or without InfoPath Forms Services
3. If you opt for ‘Document Library’ a library will be created or updated and the template can only be used in this library. If you opt for ‘Site Content Type’, you can use your template in multiple document libraries on several sites. A site content type is nothing more than a type of document with some specific properties.
In this situation you cannot opt to create a document library or a content type because you used managed code. You must select ‘Administrator-approved form template (advanced)’. We need the ‘full trust’ security level to run .NET code.
4. We can’t publish the form directly on the Sharepoint Server. First of all we must store the InfoPath form to a location which is accessible for the administrator.
B. Steps at server-side (for administrator)
1. Go to Central Administrator > Application Management. Select ‘Manage Form Templates’ in the ‘InfoPath Forms Services’ section.
2. Click on ‘Upload Form template’. The admin must browse to the location where the InfoPath form was stored by the developer.
3. Open the context menu of the uploaded file in the Form Templates List. Select ‘Activate to a Site collection’. This will publish the InfoPath Form as a Site Content Type to a site collection.
C. Steps at server-side (for site owners)
1. Go to the site collection on which you activated the InfoPath form template. Open the list where you want to install the form template.Click on Settings and select ‘Site Settings’. Click on ‘Advanced Settings’ in the ‘General Settings’ section and activate the content type management. (select ‘Yes’)
2. Now you will be able to manage the Content Types. Click on ‘Add from existing site content types’ to add the activated Form Template as Site Content in this list.
3. Go back to your list and Click on the ‘New’ Button to start a document based the uploaded Form Template.

Locking down InfoPath forms within a SharePoint Internet environment

By default SharePoint isn’t that great at restricting anonymous users to perform custom tasks and this includes submitting forms. In order to allow users permissions to submit forms and nothing else I’ve implemented the following. All of these details are being included in the work instruction that details how to create internet facing web sites with SharePoint. Currently I’ve only created a cheshireeast site but cheshirewestandchester will be the same.
I have currently only tested this with a ‘submit to e-mail’ form. I will shortly configure a ‘submit to forms library’ form and a ‘submit to spreadsheet’ form and test those.
Anonymous permissions
Turn on anonymous permissions and grant access to entire site (now trying with Lists and Libraries)
Administration of site
Most administration tasks can be performed by viewing the internal version of the site on
Administration of anonymous version of site
Administration of the anonymous site itself is made slightly more difficult. The only aspect of the site that I am aware would actually need to be configured on the anonymous site itself is the permissions for the anonymous user. If this is required you need to:
           Add an entry in your hosts file –
           Add to your proxy exclusion list in IE
You can then browse to the anonymous site,, with the ability to sign-in to administer the site
Reverse proxy configuration
To restrict users to only be able to access certain pages within the site I have added one additional rule to the reverse proxy configuration. This rule only allows reverse proxying of the following three pages: FormServer.aspx, Postback.FormServer.aspx and FormServerAttachments.Aspx.
RewriteCond Host:
RewriteCond URL (^/_layouts/FormServer\.aspx.*|^/_layouts/Postback\.FormServer\.aspx.*|^/_layouts/FormServerAttachments\.aspx)
RewriteProxy (.*)$1 [I]
Clearly if requirements change and we need to grant users access to additional pages this can be updated.

Adding a custom style sheets to InfoPath form designs

InfoPath view .xsl files contain three or four standard internal style sheets, depending on whether you have specified a color scheme. These can be identified by the attributes controlStyle=’controlStyle’, tableEditor=””TableStyleRulesID””, languageStyle=’languageStyle’, and themeStyle=’’. Never modify any of these standard internal style sheets. InfoPath often regenerates these, which will cause you to lose any changes you make to them.
You can add your own custom internal or external style sheet to any or all of the view .xsl files in your form template. The best place to add it is after the InfoPath standard style sheets because styles have reverse order precedence, meaning the last value for an identical selector property wins. If both you and InfoPath have specified a value for the border property of the table selector, whichever one appears last will override the value for the same selector property of any preceding style sheet.
You might use HTML and class selectors when writing your own styles. ID selectors will not be useful because InfoPath will not allow you to place an ID attribute on an element in the XSL. This is because InfoPath autogenerates ID attributes when it creates the view.

div {…}
.myClass {…}
#myId {…}

Internal style sheets are stored directly in the view .xsl file, just as the InfoPath standard style sheets are. If you want to use the same styles across multiple views you will need to copy the styles from one view .xsl file to another. Let’s review the steps to add an internal style sheet.

Add a custom internal style sheet:Choose Extract Form Files from the File menu.Select a location to save your extracted form files to, and then click OK.Close InfoPath to release the lock it places on your form files.Using a text editor, open your view .xsl file.Add the following code just below the last style element:

    table { FONT-FAMILY: Courier New; BORDER: solid 1px black; }
Save your view .xsl file, and then close the text editor.Reopen your form template by right-clicking the manifest.xsf file and choosing Design.
Your custom styles should now be visible in the designer. Internal styles must be updated per view .xsl file, which can create inconsistencies if you forget to update one of the .xsl files. If you want to use the same styles across multiple views, you should consider using external style sheets instead. You can always override external styles for a particular view by using a combination of external and internal style sheets.

External style sheets exist in separate .css files. They must be added to the form template as resource files as well as referenced in any view .xsl file that will use them. By using external style sheets you maintain a consistent set of styles across all of the views that reference them. Let’s review the steps to add a custom external style sheet named myCustomStyleSheet.css.
Add a custom external style sheet as a resource file:Choose Resource Files from the Tools menu.In the Resource Files dialog box, click Add.In the Add File dialog box, navigate to and select the myCustomStyleSheet.css file, and then click OK. Figure 1 shows the file added as a resource.Click OK to close the Resource Files dialog box.

Figure 1. The myCustomStyle.css file has been added as a resource file.
Link to a custom external style sheet from your view .xsl file:Choose Extract Form Files from the File menu.Select a location to save your extracted form files to, and then click OK.Close InfoPath to release the lock it places on your form files.Using a text editor, open your view .xsl file.Add the following code just below the last style element:

Save your view .xsl file, and then close the text editor.Reopen your form template by right-clicking the manifest.xsf file and choosing Design.
Your custom styles should now be visible in the designer. If you added the link element to the view .xsl file before you added the .css file as a resource, or if you later update the resource file, your updates will not be visible in the designer until you save and reopen your form template. They will, however, be visible in the form preview before you save and reopen your form template.
As long as your internal and external style sheets appear last you should not have any trouble with InfoPath overriding any of your values. However, if a scenario is encountered where a value in one of the InfoPath standard style sheets is still causing you trouble by overriding your value, add the !important declaration to yours. This will force your value to always be chosen.

table { FONT-FAMILY: Wingdings !important; }
Finally, it should be noted that inline styles are normally chosen over internal or external styles because they appear last. The !important declaration on an internal or external style will override a value on an inline style unless the inline style also uses the declaration. In other words, the !important declaration also follows the reverse order precedence.

InfoPath form Hyperlink Open in Same Window

Problem: The hyperlink control in a browser enabled infopath form opens up in a new window. This might not be a good thing as a usability perspective. It might work for some and might not for many. This post is for those ‘many’.
Note: This solution is valid only for the forms with managed code behind.
The solution I have is very trivial. Just drop a button on the form, stylize it to change its look and feel like an hyperlink. Then on the button click event of the form, just redirect the page to the URL you wanted to. There is a catch or two here.
A) On the click event, you make sure that the existing web request is completed before redirecting to your desierd page. So the code should look something like this:
HttpContext.Current.Response.Redirect(””,  false);
Passing the second parameter as ‘false’ we are ensuring that the current web request is completed and then redirected.
B) To make the button to be a hyperlink you need to do the following:
Right click the button select ‘borders and shading’, select None under presets. Then under the ’shading’ tab select the radio button for ‘No color’. Then change the font color to blue(hyperlinks are usually blue) and make it underlined.
After doign all this there is still one thing that remains, i.e the mouse turning into a hand on hover over the button. To accomplish this, from file menu, select save as source files. From the source files, edit the view1.xls file, to set the style to cursor:pointer for the button element. Then open up the manifest.xsf in design mode. You will see the button as an hyper link including mouse hover.
Update (09/03/09):
There is a kind of caveat for the above implementation. Whenever the Response.Redirect is done, the new page from code behind of the InfoPath Form, eventhough the page is redirected, the URL in the browser address bar remains the same. It behaves as the Server.Transfer method.
To fix this anomaly the workaround is redirect to an intermediary page which in turn redirects to the actual page you want to redirect. The intermediary page could be a simple page with java script redirect method.

How to implement an InfoPath 2007 clear button

Creating a clear button is quite straight forward in InfoPath. Basically you have to set up a rule to clear the content from each field on the form. This can be done with the following steps:

Add a button to your Form, call it ‘Clear’
Add a rule to the button
Do not set a condition to the rule
Add an action to set each field value to be blank / empty
Click OK, done.

Problems publishing a browser enabled form using InfoPath 2007

This is a checklist to follow if you are having problems with publishing InfoPath 2007 browser-enabled forms to Microsoft Office SharePoint Server 2007. A typical error message you receive in this case is

“This form template is browser-compatible, but it cannot be browser-enabled on the selected site”

… with an ugly yellow color. Here’s what to check before you’re going crazy:

Install Microsoft Office Forms Server 2007 (independent product) on the SharePoint box if the Office server suite you use is lower than Enterprise (or if you are using Windows SharePoint Services 3.0). The Forms Services support is included in the Enterprise Office Server suite.

After installed Forms Server, you’ll have a InfoPath Forms Services section at the Application Management page. To go here, click on Start -> Administrative Tools -> SharePoint 3.0 Central Administration and choose the Application Management tab on the top of the page. Click on Configure InfoPath Forms Services in the InfoPath Forms Services section and check both “Allow users to browser-enable form templates” and “Render form templates that are browser-enabled by users” checkboxes, then OK this page

Open your SharePoint site, click on Site Actions -> Site Settings, select Site collection features under Site Collection Administration and activate InfoPath Forms Services support

Start designing your form with the InfoPath 2007 client. In InfoPath, click on Tools/Form Options, select the Compatibility category and check the “Design a form template that can be opened in a browser or InfoPath”, then click OK. In the case if you miss this one and your form is browser-compatible, you get a warning message while publishing your form saying that “The server is running InfoPath Forms Services, but the compatibility settings for this form template is InfoPath only”.

Make sure that your form is browser-compatible. You can use the design checker task pane in the InfoPath 2007 client to perform this task.

Publish your form onto a SharePoint 2007 library. In the wizard, at step 3, check the “Enable this form to be filled out by using a browser” checkbox and finish publishing.

At the end of the publishing wizard, select “Open this document library” and click on Close. This will open the document library in the browser. Click on Settings/Form Library Settings, then click on Advanced Settings and select the “Display as a Web page” option in the Browser-enabled Documents category. If you don’t choose this option, the form will be opened in InfoPath if it’s installed on the client. Otherwise, it’s going to be opened in the browser.