+ Start a Discussion
SFDCDevQASFDCDevQA 

Need to Tab a Related List NOT Page

I'd like to essentially duplicate the Account Page via visual force but have the related list of opportunities have tabs to seperate different opportunities.  So it would be in its same spot down the page but instead of just one list of Opportunities there could be Tabs for the different stages the opps are in or something like that.  I've looked all over google but am only finding people Tabbing the actual page layout not a related list within a page.  Is this possible?

 

thanks,

Amanda

Best Answer chosen by Admin (Salesforce Developers) 
AJSFDCAJSFDC

It is possible.. Instead of using standard related list you you need to build your list from your controller and display using pageblocktable in VF.

 

Cheers,

J

All Answers

AJSFDCAJSFDC

It is possible.. Instead of using standard related list you you need to build your list from your controller and display using pageblocktable in VF.

 

Cheers,

J

This was selected as the best answer
Tanvir AnsariTanvir Ansari
As suggested you will have to do using VF & Apex where the logic will be to query related opportunities in different stages and group them. create tabs based on stage & display the relevant opportunities.
SFDCDevQASFDCDevQA

Here's what I have so far with just two subjects (custom field on opportunity) but I am getting an empty related list.  I'm showing the regular opp related list and then my new one for now so I can verify that everything shows up but the new one is blank...doesn't have anything in it.  Screenshot Attached

 

 

 

 

SFDCDevQASFDCDevQA

My controller is thus:

public class AccOpportunityListExtensions{
      Public List<Opportunity> opp1{get;set;}
      public List<Opportunity> subject1{get;set;}
      public List<Opportunity> subject2{get;set;}
      public List<Opportunity> subject3{get;set;}

       public AccOpportunityListExtensions(ApexPages.StandardController controller) {
          opp1=[select id, name, subject__c from opportunity where accountID=:ApexPages.currentPage().getParameters().get('accountid')];
          for(Opportunity op:opp1) {
             if(op.Subject__c =='General Chemistry') {
                 subject1.add(op);
 }else if (op.Subject__c =='Biochemistry') {
                subject2.add(op);
}else {
          subject3.add(op);
}
}
}
}

 

And my Page is thus:

<apex:page standardController="Account"  extensions="AccOpportunityListExtensions" showHeader="true">
   <chatter:feedWithFollowers entityId="{!Account.ID}"/>
   <apex:detail subject="{!account}" relatedList="false" title="true"/>
   <apex:relatedList list="Contacts"/>
<apex:relatedList list="OpenActivities"/>
<apex:relatedList list="ActivityHistories"/>
<apex:relatedList list="Opportunities"/>  
<apex:pageBlock >
   <apex:pageBlockTable value="{!subject1}" var="sub1">
       <apex:column >
               <apex:outputField value="{!sub1.name}" />
       </apex:column>
</apex:pageBlockTable>
  <apex:pageBlockTable value="{!subject2}" var="sub2">
 <apex:column >
               <apex:outputField value="{!sub2.name}" />
       </apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:relatedList list="Cases"/>
<apex:relatedList list="AccountPartnersFrom"/>
<apex:relatedList id="Attachments" subject="{!Account}" list="NotesAndAttachments" title="Google Docs, Notes, & Attachments"/>
 </apex:page>

 

SFDCDevQASFDCDevQA

It's getting there now.  I totolly changed the controller to something else and now it is pulling the right ones, although getting the correct columns is my hiccup now but I'll keep messing with that on my own for awhile.  The controller I ended up using is below.  Please let me know if there's anything majorly wrong with doing it this way.  thanks

 

public class sampleDetailPageOpp {

    Account a;
   
    public sampleDetailPageOpp(ApexPages.StandardController controller) {
        a = (Account) controller.getRecord();           
    }   
   
    public List<Opportunity> getSubject1() {
        return [select id, name, stagename, closedate, subject__c from Opportunity where accountid = :a.id and subject__c = 'General Chemistry' order by closedate];   
    }
    
    public List<Opportunity> getSubject2() {
        return [select id, name, stagename, closedate, subject__c from Opportunity where accountid = :a.id and subject__c = 'Biochemistry' order by closedate];   
    }
    public List<Opportunity> getSubject3() {
        return [select id, name, stagename, closedate, subject__c from Opportunity where accountid = :a.id and subject__c <> 'General Chemistry' and subject__c <> 'Biochemistry' order by closedate];   
    }
}

Tanvir AnsariTanvir Ansari
You need to create dynamically the subjects tab instead of doing static, that way if a new subject is added, you will not be needed to code the controller, VF page , the test class again.
SFDCDevQASFDCDevQA

How would I get it to pull the list of subjects dynamically?

 

Thanks,

Amanda

SFDCDevQASFDCDevQA

How can I get it to dynamically pull the subjects?  So far the only examples I've seen are specifically programming out each tab.

 

Thanks,

Amanda