Protiviti / SharePoint Blog

SharePoint Blog

December 01
Re-directing Your Users After Submitting New Items to a List in SharePoint

Have you or your client ever had the need for a "submit" button which allows users to add new items to a list? Do you find it annoying when you get re-directed back to the list view instead of the page you were on prior to making your submission? Wouldn't it create a better experience for your users if they were directed back to the page they were on before they made their submission?

If you answered "yes" to any of the questions stated above, you're in the right place! 

In this tutorial you will learn how to create a "Submit" button that redirects your users back to the page they were on prior to completing or canceling the new submission form. It is important to note that this method can be used in both SharePoint 2010 and 2013 platforms. The process stays the same regardless of which platform you are using. Awesome huh? 

Before we get started, we'll need to make sure our list is set up with everything we need.

User case example: Client-ABC needs a list to store "Best Practices" information for different departments in the company. They would like the ability for their employees to submit new "Best Practices" to this list for approval, but they don't actually want their users to see the entire list of submissions. 

This poses a bit of a problem because once a new item has been submitted to a list, users get re-directed back to the "All Items" list view once they have completed or cancelled their submission. That functionality might be ok for other scenarios, but in this particular case, our client does not want their employees to be directed back to the list view. Instead they would like their users to be re-directed to the page they were on prior to submitting their items to the list.

So, the first thing we must do is set up our list. For the purposes of this tutorial, my list will be very basic, but your list can be as complex as you need to make it.

Creating your list: 

List name: "Best Practice Submissions"

Columns needed: (Remember to create these at the root of your site.)

Title - This is the name of the "Best Practice". (This column is attached to your list by default, so there is no need to create a column for this.)

Description - Describes the "Best Practice"

Department - The department in which the "Best Practice" is applicable

Important Note: Rolling up information from lists can be quite difficult (and sometimes impossible) if columns are not created at the root of your site. So always make sure to create your columns at the root, and then attach them to the list, as opposed to creating them directly on the list itself. You’ll save yourself a lot of headaches this way.

1. Create all necessary columns at the root of your site by navigating to “Site Settings” then clicking “Site Columns”

jessica11.12.151.PNG
jessica11.12.152.PNG


2. Once all your columns have been created, create your "custom" list. Navigate to “Site Contents” by clicking “View All Site Content” from within the “Site Actions” menu. 

jessica11.12.153.PNG

3. Click “Create” then select “Custom List” from the pop-up menu. Give your list a name.

For the purposes of this tutorial I will name my list “Best Practice Submissions”. Click “Create” to save your list.

jessica11.12.154.PNG
jessica11.12.155.PNG


4. Once your list has been created, SharePoint will direct you to the standard list view. Take notice that your list is currently empty. We will fill it with items by using our “Submit” button eventually, so for now, an empty list is just what you want.

jessica11.12.156.PNG

5. Once your list has been created, we must attach the appropriate columns to the list so we can store our “Best Practice” information. Navigate to list settings to attach your columns by clicking the “List” tab within the ribbon, then clicking the button for “List settings.” 

jessica11.12.157.PNG

6. Once within “List Settings” you can attach the necessary columns to your list. In this case we are attaching the following columns: “Description” & “Department” You do not need to attach the “Title” column as it is already attached to your list by default. Click the “Add from existing site columns” button to add your previously created site columns to the list. 

Jessica11.12.158.PNG

7. Add your columns to the list by clicking the “Add” button, then clicking “OK”.

jessica11.12.159.PNG

You should now see all the appropriate columns attached to your list. 

Jessica11.12.1510.PNG

8. Once all of your columns have been attached to your list, we’re ready to create the “Submit Your Best Practice” button that will eventually direct your users away from the list view once a Best Practice has been submitted. However, before we can do that, we must figure out the URL for the New Item form since this is what we want our button to open up upon click. 

Navigate to your “Best Practice Submissions” list and right click the “Add new item” button and select “Open Link in New Tab”. This step is important as it will reveal the URL to the new item form we will link our “Submit” button to. 

Jessica11.12.15.11.PNG

Notice the “NewForm.aspx” URL that appears in your web address field. This is the URL we will want to use for your submit button hyperlink. Leave this window open as you’ll want to copy this URL later.

Jessica11.12.1512.PNG

9. Now that we know the URL we need to use for our “Submit” button hyperlink, in a new browser window, navigate to the page in which you want your “Submit A Best Practice” button to live. You can add your link in several ways. It could be a summary link webpart that has an image associated with it, or it could be a text link within a content editor or page content area. It’s really up to you, no matter which way you choose, the same principles apply.

For this tutorial we will add a link to the page content area. Put your cursor in the “Page Content” field of your page. Add a “Link From SharePoint” via the “Insert” tab within the ribbon. 

Jessica11.12.1513.PNG

This should bring up an “Insert Hyperlink” window. Add your “Submit a Best Practice” display text for the URL, then copy the NewForm.aspx URL from the previous step (Step 8) and paste it into the “Address” field. Delete the “?RootFolder=” portion of the URL so it ends with “.aspx” and press “Ok”

Jessica11.12.1514.PNG

At this point, if you save your page and test, your “Submit a Best Practice” button should open a "New Item" form when clicked.  This is exactly what we want at this stage.

Jessica11.12.1516.PNG

Go ahead and test this by clicking the button, filling out the new item form, attaching your documents, then clicking “Save”

Jessica11.12.1517.PNG

Your new item has now been saved to the list, but notice how you are still directed back to the list view after creating your submission?  This is not what we want. We want the user to go back to the page they were on previously before submitting/cancelling their item. To do this we must add something to the URL for your “Submit” button.  

Jessica11.12.1518.PNG

10. Navigate back to the page with your submit button and edit the page. Place your cursor inside the “Submit A Best Practice” link you’ve created. Click the “Link Tools” tab to edit the URL for your button. 

Jessica11.12.1519.PNG

We will still be using the “New Form” URL we used before, we just need to add an additional URL for the page that we want our users to get directed to. 


If you want the user to be directed back to the page featuring the Submit button, copy the URL for that page and add it to the end of your existing NewForm.aspx URL like as stated in the example below... 


So instead of linking to this URL like we did previously: 

http://sharepoint.protiviti.com/training/Lists/Best Practice Submissions/NewForm.aspx

(This format opens a new item form, and re-directs users to the list view once the item has been submitted.)


Link to this URL instead by adding “?Source=” at the end of your existing URL, then pasting the other URL for the page you want your users directed to: 

http://sharepoint.protiviti.com/training/Lists/Best%20Practice%20Submissions/NewForm.aspx?Source=http%3a//sharepoint.protiviti.com/training/Pages/Redirecting-Users-Demo.aspx

(This format opens a new item form, but upon save/cancel it redirects the user to your page of choice.)


URLs explained:

http://sharepoint.protiviti.com/training/Lists/Best%20Practice%20Submissions/NewForm.aspx?Source=http%3a//sharepoint.protiviti.com/training/Pages/Redirecting-Users-Demo.aspx

The yellow highlighted portion of the URL opens your new item form. The blue highlighted portion of the URL is what re-directs your user. By adding  “?Source=” at the end of your existing URL, you are effectively telling the button to open the new item form first, but to direct the user to a different page once the form is saved or cancelled. Unlike returning users to the list view like it usually does.

Important Note: Don’t worry about the “%20” sections of the URL. SharePoint replaces blank spaces in URL’s with “%20” to ensure the links can be read by SharePoint. So as long as you copy your URL’s correctly, SharePoint will do what it needs to do in order to make sure the links are proper.

If you save your page and test your newly linked “Submit a Best Practice” button, you should be directed to the new item form first, and then re-directed to the page you declared once the form has been either submitted or cancelled. Voila, all done. 


Quick Launch


© Protiviti 2020. All rights reserved.   |   Privacy Policy