Friday, January 15, 2010

Redirect users to a custom location when an Infopath form is closed

Scenario:
How to redirect users to a custom location when a web-based Infopath form is closed?

Explanation:
In SharePoint, when a web-based infopath form that is opened from a FormsLibrary is closed, by default the user is redirected to the location where the form is opened from.
It is possible to redirect users to a custom location.
When SharePoint opens a web based Infopath form when a user clicks on a form from FormsLibrary, it appends a QueryString parameter called "Source" to the QueryString. When the form is closed, the request is transferred back to the value in the "Source" parameter. It is by behaviour of SharePoint. SharePoint uses the same mechanism to remember previous locations. For ex: In Site Settings, when we navigate through galleries, you will notice this.

For an existing infopath form:

http://[Website Url]/_layouts/FormServer.aspx?XmlLocation=[Web]/[FormsLibraryName]/[FormName].xml&DefaultItemOpen=1&FileName=[FormName].xml&Source=[Custom redirection location]?[Optionalparameters]{Parameter=[Parameter]%26Parameter1=[Parameter1]}

For a new infopath form:


http://[Website Url]/_layouts/FormServer.aspx?XsnLocation=[Site Collection Url]/FormServerTemplates/[Infopath Form Name].xsn&SaveLocation=[Custom redirection location]&DefaultItemOpen=1&FileName=[FormName].xml&Source=[Custom redirection location]?[Optionalparameters]{Parameter=[Parameter]%26Parameter1=[Parameter1]}

3 comments: