2

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?

1 Answer 1

1

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

1
  • I actually just wrote against the built-in SP web services in the end. But I'll check out the SPServices library. Thanks! Commented May 7, 2012 at 12:33

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.