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've got a List in Sharepoint 2010 and I've created a "related item" which has a link to my master list which is set to unique values (so for each item in my master list there is 0...1 child items).

I have got a standard "Related item View" section added to my DispForm.aspx which shows the related item and allows me to click it.

What I would like to do is replace the Related Item View with a button and then add a javascript function which would either open the related item OR would open the "NewForm.aspx" and pass the appropriate ID.

As far as I can tell what I need is some way of retrieving the Id of the related item, with that I can call "DispForm.aspx?ID="+id and if there is no Id then call "NewForm.aspx?MasterId="+MasterID.

How do I read the Id of the child item, if it exists?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Dave,

The best option is to use SPServices (http://spservices.codeplex.com) library to access the built-in SP web services from jQuery/Javascript on the client-side.

That's what I did in this article, doing something similar to determine if the user had already taken a survey: https://www.nothingbutsharepoint.com/sites/eusp/Pages/jquery-to-the-rescue-requesting-a-review-only-once-per-user.aspx

The focus of the article is that if the user has already taken the survey, they're taken to the existing one to read it; if they haven't taken it, then I pass the Survey name into the NewForm as a querystring.

Let me know if you get stuck, or I'm missing that makes this example not quite fit for you.

Blessings, Jim Bob

share|improve this answer
    
I actually just wrote against the built-in SP web services in the end. But I'll check out the SPServices library. Thanks! –  Dave Alger May 7 '12 at 12:33
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.