We help IT Professionals succeed at work.

Is there a way to dynamically create a direct link to the first item on a filtered list?

colonelblue
colonelblue asked
on
I have a list filtered by "date added". Currently I have a link on a nav bar that goes to that list where from there one can access the latest document added. Is there a way to have a link that automatically goes to the latest added  document without having to first go to the list and then clicking on the latest?

Thank you in advance.
Comment
Watch Question

Hi! I guess you cannot do that without some coding. The simplest solution I see, is to create you custom application page that will simply redirect user to the lastest document. So you can add link to your application page to the nav bar and when user clicks it, he will be redirected to the document (the url of document will be created dunamically in application page code).
If you need futher assistance on this let me know!

Author

Commented:
Hello and thank you. I am not sure how you mean. Create an application page ?> How does it dynamically create? Any chance of an example.

Lets say I have 3 documents in a list:
Apple1.pdf Date added 10/30/11
Apple2.pdf Date added 11/2/11
Banana3.pdf  Date added 11/1/11

It is filtered by lasted date added: That would make the document Apple2.pdf the latet.

I would like a dynamiic link to the lastest added link on the above list.
How do I do that?

Thank you in advance.
Hi!
The idea is to create url dynamically in server code and then redirect user to created url.
Your question seemed interesting to me and I wrote a small article on this in my blog. So for details please see http://www.spsamples.com/2011/11/creating-direct-link-to-lastest.html. There you can aslo find solution package and source code. If you need futher assistance on this let me know!

Author

Commented:
This looks fantastic!
I will look at it now and post my results.
YOU are a genius!
Thank you.

Author

Commented:
Hello Ivan I tried to install the wsp using

stsadm.exe" -o addsolution -filename c:\SPSamples.RedirectionPage.wsp
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
\stsadm.exe" -o addsolution -filename c:\SPSamples.RedirectionPage.wsp

I got this error.
Please help.

Solution manifest for solution '38e85f30-b2e3-491f-a09a-04053d6c645a' failed val
idation, file manifest.xml, line 2, character 110: The 'SharePointProductVersion
' attribute is not declared.
c:\SPSamples.RedirectionPage.wsp: The Solution installation failed.


Do you use SharePoint 2007? The package is for SharePoint 2010, if you use SharePoint 2007, I can provide package for that too.

Author

Commented:
My apologies , yes it is SharePoint 2007.

Author

Commented:
Hello Ivan, and thank you. I see that in the dropdown that shows up , lists and some libraries show up. Curious however what if it is document libraries I'd like instead of lists.

Also does this just make one redirect? What if I needed several?

Thank you again.
Hi! DropDown list shows entire Lists collection (which contains all Lists and Libraries) from current web - so you have to see all lists and libraries on your web (not subwebs). What do you mean by several redirects? You can't make a one link to several targets at once.

Author

Commented:
Hello Ivan.
That is odd because I don't see all the libraries, esp the one in need. Am I doing something wrong? I do have some subsites.

What I meant for more than one is what if I had 4 different libraries that I wanted to make a dynamic link each respectively. At the moment if I use the method you kindly created, isn't that just good for one redirect using that redirect.aspx link?

Thanks again.
Hi! I see, so do you want to redirect to library on subsite? The solution now is not intended to read data from subsites. So I will update solution to read data from subsites and to have several redirect pages.

Author

Commented:
Ivan thank you!
Welcome ) Here is updated package: https://ivanvagunin.opendrive.com/files?50444389_rhhO4. I did not tested it much, so if find any bug - let me know please.
To get redirection for different page add "p" parameter to settings page query strings.
E.g.:
 /_layouts/SPSamples/RedirectionSettings.aspx?p=1 (corresponding redirection page is _layouts/SPSamples/Redirection.aspx?p=1)

/_layouts/SPSamples/RedirectionSettings.aspx?p=anotherkey (corresponding redirection page is _layouts/SPSamples/Redirection.aspx?p=anotherkey)

Author

Commented:
Hello Ivan, I was out sick yesterday. I will check it out tonight and let you ASAP.
Again MY SINCERE gratitude! :)

Author

Commented:
Hello Ivan, I know how to install a wsp, but how do I install your newer version over the
other?


This how I install it but I do not think it's updating the older one.

"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addsolution -filename c:\SPSamples.RedirectionPage.wsp
Hi! You need to uninstall previously installed package, because SharePoint 2007 does not support solution upgrade. So first you need to rectract and delete old package:
1) "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o retractsolution -name SPSamples.RedirectionPage.wsp
2) "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deletesolution -name SPSamples.RedirectionPage.wsp
Then add and deploy new package:
3)"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o addsolution -filename c:\SPSamples.RedirectionPage.wsp
4) "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\stsadm.exe" -o deploysolution -f
-name SPSamples.RedirectionPage.wsp -local -allowGacDeployment

Author

Commented:
Again my apologies for my late reply.


YOU ARE JUST SIMPLY AMAZING!
Thank you so much for your genius AND generosity!

Wishing you the best!.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.