There are times when you want a user to add an item to a list without displaying the list, either before or after they fill out the “New Item” form.
To get them to the form is easy. Go to the list, click the New button and note the URL. Copy the URL and paste it as a link in an Announcement, a links list or a Content Editor Web Part. When the user clicks your link they will go directly to the New item page.
But… when they click OK they will the go to the list, not back to your page.
The fix is easy... Add “source=” to the end of the link.
1) Go to the list and click the new button. You will see a URL like:
2) copy the URL and change the part after Source= to the desired destination. The following will send them back to your home page:
Absolute or Relative?
Best practice would be to use a relative URL (no HTTP or server name) so your site will work when you have internet and intranet access to the same site. Something like "Source=/sites/sales/" or "Source=/sites/sales/mycustompage.aspx".
To return to the home page add this URL as a link in your Announcement, a links list or a Content Editor Web Part:
Absolute:
Relative:
/sites/sales/Lists/Tasks/NewForm.aspx?RootFolder=%2FLists%2FTasks&Source=%2Fsites%2Fsales
In the examples above I did not always escape the slashes: / = %2F
Any slash after the "?" should be escaped.
.

0 comments:
Post a Comment