Saturday, October 1, 2011

Specifying Return URL/ Source URL for SharePoint Forms

By default, when users fill out a SharePoint form, they will be navigated back to the "All Items" page after pressing OK. For example if I’m in the “Add new item” form (http://prasad/Lists/MyCustomList/NewForm.aspx) or “Edit item” form (http://prasad/Lists/MyCustomList/EditForm.aspx?ID=7) of the custom list called “MyCustomList”, I will be taken back to “All Items” view (http://prasad/Lists/MyShortCutsList/AllItems.aspx) of the custom List, once I press “Save” or “Cancel” button.

We can change this behavior by specifying a ReturnURL in the form URL by providing a value to “source” querystring. “Source” query string supports both relative URL and the full URL.

Example:
http://prasad/Lists/MyCustomList/NewForm.aspx ?Source=http://prasad/Pages/default.aspx
http://prasad/Lists/MyCustomList/NewForm.aspx ?Source=/Pages/default.aspx

Specifying source querystring as above will be taken you to the home page, when you use “Add new item” form.