0

I have the following code on my Apex component as part of a custom lead conversion process. The user can select an account here OR create a new account. I want to remove the "Create New Account: xxx" from the picklist. Any idea how to do so?

<apex:selectList value="{!selectedAccount}" size="1" 
    multiselect="false" id="accountList">

    <apex:actionSupport event="onchange" 
        action="{!accountChanged}" 
        rerender="opportunityName, ViewLink"
         />     
    <apex:selectOptions value="{!accounts}"/>

</apex:selectList>

I figured it out, its part of the controller

private void populateAccounts() {

    if (leadConvert != null) {

        string company = leadConvert.Company;

        // find any accounts that match the SOSL query in the findCompany() method  
        Account [] accountsFound = findCompany(company + '*');

        accounts = new List<selectOption>();

        if (accountsFound != null && accountsFound.size() > 0) {

            // if there is at least 1 account found add a NONE option and a Create New Account option
            accounts.add(new SelectOption('NONE', '-None-'));

            accounts.add(new SelectOption('NEW', 'Create New Account: ' + company ));

            // for each account found, add an option to attach to the existing account
            for (Account a : accountsFound) {

                accounts.add(new SelectOption(a.Id, EXISTING + a.Name));
            }

        }

        else {

            // if no accounts matched then simply add a Create New Account option
            accounts.add(new SelectOption('NEW', 'Create New Account: ' + company ));

            system.debug('no account matches on company ' + company);
        }

        //the default opportunity name will be the lead's company
        opportunityId.Name = company + '-';
    }

    else system.debug('leadConvert = null');

}
1

If you don't want to add option in picklist. Just comment this line in code

//accounts.add(new SelectOption('NEW', 'Create New Account: ' + company ));
| improve this answer | |

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.