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?