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
Satish Singh 14Satish Singh 14 

Opportunity in the account reated list

 I want to show my all Opportunity in the account reated list with following condition with it -
  1. Stage Name should be Closed won and Close Date in future .
  2. List shows the Opportunity Name, Closed Date , Stage Name and Amount.
 
 Thaks in aadvance.
Best Answer chosen by Satish Singh 14
Akshay_DhimanAkshay_Dhiman

Hi Satish,
you can use this code and procedure.
Controller :
public class getOppertunityClosedWon {
    public List <Opportunity> CloseWonOppList {get;set;}
    
   public getOppertunityClosedWon(ApexPages.StandardController controller) {
       Date todayDate =Date.today();
       String AccId = ApexPages.currentPage().getParameters().get('id');
       CloseWonOppList =  [select id , Name,Type,Amount,StageName,CloseDate from Opportunity where  AccountId =:AccId and StageName ='Closed Won' AND CloseDate >:todayDate limit 50];
     
   }
}
Visualforce page -


<apex:page extensions="getOppertunityClosedWon" standardController="Account">
 <apex:form >
     <apex:pageBlock >
         <apex:pageBlockSection title="All Prospecting Opportunity" collapsible="true" columns="1">
             <apex:pageBlockTable value="{!CloseWonOppList}" var="op">
                 <apex:column value="{!op.Name}" />
                 <apex:column value="{!op.CloseDate}"/>
                 <apex:column value="{!op.StageName}"/>
                 <apex:column value="{!op.Type}" />
                 <apex:column value="{!op.Amount}"/>
              </apex:pageBlockTable>
         </apex:pageBlockSection>
         
     </apex:pageBlock>
 </apex:form>
</apex:page>



After writing above  code do the following :
1 Go to edit layout on account detail page

User-added image

2. Select a section and drag down where you want to place it.

User-added image

3. Goto visualforce page and drag within the section you just added.

User-added image

4.Now Save the layout and your related list of opportunity will shown just below of the account details page.

User-added image



Hope This this will help you .
If this answers your query please mark this question as a solved so that it can be filtered out from unsolved questions.

Regards
Akshay

All Answers

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Satish, Hope it will be helpful.

Thanks
Rahul Kumar
karthikeyan perumalkarthikeyan perumal
Hello, 

Follow these steps: 

Create lookup relationship from Opp relate object to Account like below. 

User-added image

User-added image

Create new process builder with following the same. ( its helps to move update the record  with stage equal to "closed Won").

Process Builder :

User-added image

Criteria Section: 
User-added image

ImmediateAction:

User-added image

Finally activate your process builder. and do the testing. 

Hope this will help to achive your goal. 

Thanks
karthik
 
Akshay_DhimanAkshay_Dhiman

Hi Satish,
you can use this code and procedure.
Controller :
public class getOppertunityClosedWon {
    public List <Opportunity> CloseWonOppList {get;set;}
    
   public getOppertunityClosedWon(ApexPages.StandardController controller) {
       Date todayDate =Date.today();
       String AccId = ApexPages.currentPage().getParameters().get('id');
       CloseWonOppList =  [select id , Name,Type,Amount,StageName,CloseDate from Opportunity where  AccountId =:AccId and StageName ='Closed Won' AND CloseDate >:todayDate limit 50];
     
   }
}
Visualforce page -


<apex:page extensions="getOppertunityClosedWon" standardController="Account">
 <apex:form >
     <apex:pageBlock >
         <apex:pageBlockSection title="All Prospecting Opportunity" collapsible="true" columns="1">
             <apex:pageBlockTable value="{!CloseWonOppList}" var="op">
                 <apex:column value="{!op.Name}" />
                 <apex:column value="{!op.CloseDate}"/>
                 <apex:column value="{!op.StageName}"/>
                 <apex:column value="{!op.Type}" />
                 <apex:column value="{!op.Amount}"/>
              </apex:pageBlockTable>
         </apex:pageBlockSection>
         
     </apex:pageBlock>
 </apex:form>
</apex:page>



After writing above  code do the following :
1 Go to edit layout on account detail page

User-added image

2. Select a section and drag down where you want to place it.

User-added image

3. Goto visualforce page and drag within the section you just added.

User-added image

4.Now Save the layout and your related list of opportunity will shown just below of the account details page.

User-added image



Hope This this will help you .
If this answers your query please mark this question as a solved so that it can be filtered out from unsolved questions.

Regards
Akshay
This was selected as the best answer
Satish Singh 14Satish Singh 14

Hey Thank you Akshay.

Akshay_DhimanAkshay_Dhiman
Hi Satish,
Thanks for selecting my answer as a best. It's my pleasure to help you!
Regards,
Akshay