Change the default Redirect Location of “Display Item Form” close button in SharePoint

Zeus-Sharepoint-Blog-Image-Feature
 
Most of the time, people are using the SharePoint’s Display item form to display their list content in a page. By default, the Display item form’s close button redirect you to the default view of the library where your page/document exists or where your item exists. In some cases, some people want to change this redirect URL. We have several ways to achieve this. In this case, we can use JavaScript. I’ll demonstrate it using a page parameter on how we can change the Redirect page of Display item form’s close button. In this example I have a list called “News” and I’m going to show the latest news in a different SharePoint page called “News” which is inside the “Site Pages” library.
 
Currently this is my News list:
 
Default Display Item form:
“http://spfoundation/_layouts/15/start.aspx#/Lists/News/DispForm.aspx?ID=1&Source=http%3A%2F%2Fspfoundation%2FLists%2FNews%2FAllItems%2Easpx”
This means after you click on Close button you will automatically redirect to “News” list default “AllItems.aspx” page. It looks like this:
 
1
 
So the goal is to change the “&Source” Parameter. Here’s how:
 

  • Create a new Page. (In my example I created a “Wiki” Page inside my “Site Pages” library. I inserted a header called “Latest News“)

2
 

  • Open the page using “SharePoint Designer

 
3
 

  • Insert a new Display Item form

 
4_1
 

  • Select your Display Item Form and click “Add/Remove Columns” button in the ribbon. It then opens the “Edit Column” window.

 
6
 

  • Remove unnecessary columns. In this example, I used “Title” and “Content” column.

 
7
 

  • Sort using “ID” to show latest Contents. (or you can skip this step)

 
8
9
 

  • Find <xsl:template name=”dvt_1.rowview”> tag.

 
10
 

  • Change the table data (<td>) content like below:

 
11
 

  • Select the Display Item Form and click the Parameter button. This will open the Data View Parameter window.

 
12
 

  • Create a new Parameter called “Source” and for the “Default Value” type in your redirect page URL. In this example, I was redirected to my home page. Click OK.

 
13
 

  • Add our new Parameter at the end of your column URL. In this example, it’s “Title” column URL.

17
 

  • Save and close your page. That’s it. This is how the page looks like:

 
15
This is my new Display item Form:
“http://spfoundation/Lists/News/DispForm.aspx?ID=1&Source=http://spfoundation
previously it looks like this: “http://spfoundation/_layouts/15/start.aspx#/Lists/News/DispForm.aspx?ID=1&Source=http%3A%2F%2Fspfoundation%2FLists%2FNews%2FAllItems%2Easpx
 
16
 
Happy Coding! Smile
 
For more article like this visit: http://sptricks.com/
 

Social Media

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, Just News and Updates.

Visit Other Pages

On Key

Related Posts

Twitter
Facebook
LinkedIn