function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MeighanSFMeighanSF 

Custom Object Sibling Object Records on Visualforce Page

Hello,

I have a custom object "Success__c" that I am attempting to create a visualforce page for.  I would like to have the parent (MD relationship via account__c) Account fields on the page, as well as the sibling objects from the shared parent Account, Opportunities and Health__c.  The problems I am having are as follows:
1) I am new to VF (this is my second page with the first just being a junction object with editable fields and read only parent access) so I don't know the best places to look or the best terms to =search for so google has not been that helpful
2) Althought I have the health and successes related via a related list on the successes, the successes detail is nested and looping itself and i'm not sure what I did. (Plus I'd like this on the page not the related list.

Here is my page:
<apex:page standardController="Success__c" extensions="DetailPagesuccess">
<apex:form >
 <apex:pageMessages />
 <apex:detail relatedList="true"></apex:detail>
<apex:pageblock id="CustomList" title="Related Health"  >
   <apex:pageBlockTable value="{!ahealth}" var="ahc" rendered="{!NOT(ISNULL(ahealth))}">
        <apex:column value="{!ahc.Name}"/>
        <apex:column value="{!ahc.Account__r.Name}"/>
        <apex:column value="{!ahc.Status__c}"/>
       <apex:column value="{!ahc.Go_Live__c }"></apex:column>
   </apex:pageBlockTable>
   <apex:outputLabel value="No records to display" rendered="{!(ISNULL(ahealth))}" styleClass="noRowsHeader"></apex:outputLabel>
 </apex:pageblock>
</apex:form>
</apex:page>
Here is my extension:
public class DetailPageSuccess {
    private List<Health__c> ahealth;
    private Success__c success; 
    public DetailPageSuccess(ApexPages.Standardcontroller controller) {
        this.success= (Success__c)controller.getRecord();
    }
    public List<Health__c> getahealth()
    {
        Success__c asc= [Select id, Account__r.id FROM Success__c where id = :success.id];
        if (asc.Account__r.id == null)
         return null;
        ahealth = [Select id, Name, Account__r.id, Account__r.Name, Status__c, Go_Live__c from Health__c where Account__r.id = :asc.Account__r.id];
        return ahealth;
    }
}

If you aren't able to help directly if you could please point me in the right direction I would really appreciate it.