Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm making a issue list that should have link to a document library. After registrered I want the dispform.aspx to show a link to the library with filter on the ID from the issue list.

I know ID can't be fetched from the form, but is it possible to retrieve it from the http address and put it in with the link with javascript?

/Forms/AllItems.aspx?FilterField1=look&FilterValue1=My ID from HTTP

//Stian

share|improve this question
add comment

2 Answers

In SharePoint you can use _spGetQueryParam to get a url param like your ID (details on my blog)

var id = _spGetQueryParam("ID");
var url = "/Forms/AllItems.aspx?FilterField1=look&FilterValue1=" + id;
share|improve this answer
1  
This is an absolutely brilliant find! –  Vardhaman Deshpande Aug 28 '12 at 18:41
add comment

Yes, it is possible to get item Id from display (or edit) form address. They usually have this kind of address:

Lists/Announcements/DispForm.aspx?ID=35&So 

You can parse ID attribute using this javascript:

var regex = new RegExp("[\\?&]ID=([^&#]*)");
var itemIdValue = regex.exec(window.location.href);
var itemId = itemIdValue[1];
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.