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
DaveKempDaveKemp 

sobject list items not updating controller when selected

Hi,

I have a list of Opportunities in a visualforce page populated from a SOQL query in a wrapper class

    public List<SelectOption> getnewOpportunityList(){
            List<SelectOption> newOpportunityList = new List<SelectOption>();
   newOpportunityList.add(new SelectOption( ' ' ,'---Select---'));
            newOpportunities = [Select o.Id, o.Name From Opportunity o WHERE o.AccountId = :this.parentAccount.Id ORDER BY o.Name];
            for(Opportunity temp : newOpportunities)
            {
                newOpportunityList.add(new SelectOption(temp.Id, temp.Name));
            }
            System.debug('Selected Opportunity:'+newOpportunity);
            return newOpportunityList;
     }

and this is the page that displays the list ok:
 
<apex:column >
<apex:facet name="header">New Opportunity</apex:facet>
<apex:selectList size="1" title="New Opportunity" value="{!o.newOpportunity}">
  <apex:actionSupport event="onchange" rerender="displayView2"/>
  <apex:selectOptions value="{!o.newOpportunityList}"/>
</apex:selectList>
</apex:column>
    
however, when I select an opportunity from the list, it's not updating the newOpportunity field, I'm guessing I'm either missing
something or it's not possible to use SObjects in a list like this using the SelectOption?

Any help gratefully appreciated

David
Ashish_SFDCAshish_SFDC

Hi David, 


Need some more information on the issue, how is the newOpportunity Field being updated by selecting the Opportunity?

Enable debug logs for the user who is testing this and look for the logs. 

Post a pic if i am missing the functionality. 


Regards,

Ashish