0

How to create a picklist with the return from the following method in visualforce, currently receiving the following error: Unknown property AccountCreation.AccountNames

@RemoteAction
    public static List<selectOption> getAccountNames(string categorySelected){
    List<selectOption> accByCategory = new List<selectOption>();

    for(Account acc :[SELECT Id,Name FROM Account WHERE Category_Name__c = :categorySelected]){
            accByCategory.add(new selectOption(acc.Name,acc.Name));
        }

    return accByCategory ;  

    }

Visualforce:

    <apex:selectList multiselect="false" size="1">
        <apex:selectOptions value="{!AccountNames}">
        </apex:selectOptions>
    </apex:selectList>
0

Your method needs to not have any parameters to be a valid getter:

public string categorySelected { get; set; }
public List<selectOption> getAccountNames(){
List<selectOption> accByCategory = new List<selectOption>();

for(Account acc :[SELECT Id,Name FROM Account WHERE Category_Name__c = :categorySelected]){
        accByCategory.add(new selectOption(acc.Name,acc.Name));
    }

return accByCategory ;  
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.