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
AkshuAkshu 

I want VF page for this requirement

1.created custom button on details page of account account "show" requirement is:
when click on this button show rcontacts  related to account in table format.
ShivankurShivankur (Salesforce Developers) 
Hi Akshay,

You can use following type of VF implementation to achieve this requirement.

VF Page logic:
<apex:repeat value="{!accounts}" var="accWrap">
   <apex:outputText value="User ID : {!accWrap.userId}"/>

   <apex:repeat value="{!accWrap.accounts}" var="acc">
      <apex:outputText value="Account : {!acc.Name}"/>

      <apex:repeat value="{!acc.contacts}" var="cont">
         <apex:outputText value="Contact : {!cont.Name}"/>
      </apex:repeat>

   </apex:repeat>

</apex:repeat>
Apex Class:
public class accountcontact
{
    list<AccountWrapper> wraplist=new list<AccountWrapper>();
    public accountcontact()
    {
       Map<Id, AccountWrapper> accMap=new Map<Id, AccountWrapper>();
       for(account a:[SELECT CreatedbyID,Account.Name,(SELECT      
                name,Contact.FirstName, Contact.LastName 
                FROM Account.Contacts) FROM Account])
       {
           AccountWrapper accWrap=accMap.get(a.CreatedByID);
           if (null==accWrap)
           {
              accWrap=new AccountWrapper();
              accMap.put(a.CreatedByID, accWrap);
              accWrap.userId=a.CreatedById;
           }

           accWrap.accounts.add(a);
       }

       wrapList=accMap.values();
   }

   public list<AccountWrapper> getaccounts()
   {
      return acclist;
   }

   public class AccountWrapper
   {
      public Id userId {get; set;}
      public List<Account> accounts {get; set;}
      public AccountWrapper()
      {
         accounts=new List<Account>();
      }
   }
}

You might want to make a few modification in the VF page since it shows the accounts as well.

Hope above information helps, Please mark as Best Answer so that it can help others in the future.

Thanks.
Deepika RahangdaleDeepika Rahangdale
modify VF page but getting problem 

<apex:page controller="VFDisplayAccWithContactctrl">
    <apex:form>
        <apex:pageBlock>
            <apex:pageBlockSection>
                        <apex:pageBlockTable value="{!accounts}" var="item">

                    <apex:repeat value="{!accounts}" var="accWrap">
                        <apex:outputText value="User ID : {!accWrap.userId}"/>
                        
                        <apex:repeat value="{!accWrap.accounts}" var="acc">
                            <apex:outputText value="Account : {!acc.Name}"/>
                            
                            <apex:repeat value="{!acc.contacts}" var="cont">
                                <apex:outputText value="Contact : {!cont.Name}"/>
                            </apex:repeat>
   
                        </apex:repeat>
 </apex:repeat>   
                </apex:pageBlockTable>
 </apex:pageBlockSection>  
 </apex:pageBlock>
  </apex:form> 
</apex:page>
User-added image