Design a Visualforce Page to display Opportunities by Stage. User should be able to select a Stage from a Dropdown on the Page and view all the opportunities of the selected stage
public class OppBasedOnStageC {
public Opportunity opp {get;set;}
public List<Opportunity> opportunities {get;set;}
public OppBasedOnStageC() {
opp = new Opportunity();
opportunities = new List<Opportunity>();
}
public void showOpp() {
if(opp.StageName == 'Prospecting'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Prospecting'];
}
if(opp.StageName == 'Qualification'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Qualification'];
}
if(opp.StageName == 'Need Analysis'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Need Analysis'];
}
if(opp.StageName == 'Need Analysis'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Need Analysis'];
}
if(opp.StageName == 'Closed Won'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Closed Won'];
}
if(opp.StageName == 'Closed Lost'){
opportunities = [SELECT Id, Name, StageName FROM Opportunity WHERE StageName='Closed Lost'];
}
// Add more Stages
}
}
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Greetings to you!
Below is the sample code which I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas