You need to sign in to do that
Don't have an account?
Learnerrr
Not able to see the list of stageName of opportunity in select list:--->I want to create list of opportunity stage and by selecting a stage from the list ,details of opportunity will be display for the same stage
<apex:page controller="OppotunityByList" > <apex:form > <apex:pageBlock title="Display Opportunity Details: "> <apex:pageBlockSection > <apex:outputLabel value="opportunity Name: " /> <apex:selectlist value="{!oppid}" size="1" > <apex:selectOptions value="{!oppnames}" /> <apex:actionSupport action="{!getDetails}" event="onchange" rerender="display"/> </apex:selectlist> </apex:pageBlockSection> <apex:pageBlockSection id="display" title="Account Details"> <apex:pageBlockTable value="{!SelectedOpp}" var="a"> <apex:column HeaderValue="Name" value="{!a.Name}"/> <apex:column HeaderValue="Stage Name" value="{!a.StageName}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form>
public class OppotunityByList { public String oppnames { get; set; } public String oppid { get; set; } public Opportunity SelectedOpp{get;set;} public list<selectoption> getoppnames() { list<selectoption> accoptions = new list<selectoption>(); for (opportunity p : [select id, stageName from opportunity]){ accoptions.add(new selectoption(p.id, p.name)); } return accoptions; } public void getDetails() { SelectedOpp = new Opportunity(); SelectedOpp = [SELECT id, Name, stageName FROM Opportunity WHERE stageName=:oppid ]; } }
Replace your getoppnames method with below:
Please mark this as the best answer if it solves your problem. Thanks.
Please try the below code, it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
I hope it helps you.
Kindly let me inform if it helps you and close your query by marking it as solved so that it can help others in future.
Thanks and Regards,
Khan Anas