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

How to show only Open opportunity in Opportunity tab

I have used tab insted of Related list .Can we show only oppoen opportunity under Opportunity tab related with account.
PFB snap and code
Should show only open opportunity
<apex:page standardController="Account" showHeader="true"
tabStyle="account" >
.activeTab {background-color: #236FBD; color:white;
.inactiveTab { background-color: lightgrey; color:black;
<apex:tabPanel switchType="client" selectedTab="tabdetails"
id="AccountTabPanel" tabClass="activeTab"
<apex:tab label="Details" name="AccDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
<apex:tab label="Contacts" name="Contacts" id="tabContact">
<apex:relatedList subject="{!account}" list="contacts" />
<apex:tab label="Opportunities" name="Opportunities"
<apex:relatedList subject="{!account}"
list="opportunities" />
<apex:tab label="Open Activities" name="OpenActivities"
<apex:relatedList subject="{!account}"
list="OpenActivities" />
<apex:tab label="Notes and Attachments"
name="NotesAndAttachments" id="tabNoteAtt">
<apex:relatedList subject="{!account}"
list="CombinedAttachments" />

<apex:tab label="Account Team"
name="AccountTeams" id="AccountTeams">
<apex:relatedList subject="{!account}"
list="AccountTeams" />

PratikPratik (Salesforce Developers) 
Hi Manish,

I think you will have to write an extension to this standardcontroller and there write logic to override getopportunities method to get open opprtunities (IsClosed=false).

Here is the sample code i tried and it worked:

VF Page:

<apex:page standardController="account" extensions="ovrrideopp">
  <apex:tabPanel >
  <apex:tab label="contacts" >
  <apex:relatedList list="contacts"/>
   <apex:tab label="Opprtunities" >
   <apex:pageBlock >
   <apex:pageBlockTable value="{!opplist}" var="op">
   <apex:column value="{!}"/>
   <apex:column value="{!op.stagename}"/>
  <apex:detail relatedList="false"/>


Public class ovrrideopp{
Public string accid;
public list<opportunity> opplist{get;set;}

    public ovrrideopp(ApexPages.StandardController controller) {

  accid = ApexPages.currentPage().getparameters().get('id');
  opplist= [select name,stagename from opportunity where accountid=:accid AND isClosed=False];


Let me know how it goes for you!


P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.