You need to sign in to do that
Don't have an account?
SFDC_Saurabh
Prepopulate values from apex in Multiselect picklist
Hello,
I want to update picklist values in edit form based on values available in table.
My VF page looks like :
I can only preset any one value as you can see from apex above where i selected 'Finance'.
I came to know from other forum topics that I can setup a getter setter for values variable of VF page in apex. and there the data type should be String array.
But in my case I am using standerd database field as Value variable in Vf page.
How can I prepopulate multiple values in this scenario.
I want to update picklist values in edit form based on values available in table.
My VF page looks like :
<apex:selectList value="{! Contact.assign_1_Business_Vertical__c }" multiselect="true" size="5"> <apex:selectOptions value="{!parentPicklistOptions}" /> <apex:actionSupport event="onchange" rerender="panel2,panel3" /> </apex:selectList>My controller is :
public List<SelectOption> getParentPicklistOptions() { List<SelectOption> selectOpts = new List<SelectOption>(); for ( String s : parentDepMap.keySet() ) selectOpts.add(new SelectOption(s, s)); System.debug(contact.assign_1_Business_Vertical__c); Contact.assign_1_Business_Vertical__c = 'Finance'; return selectOpts; }
I can only preset any one value as you can see from apex above where i selected 'Finance'.
I came to know from other forum topics that I can setup a getter setter for values variable of VF page in apex. and there the data type should be String array.
But in my case I am using standerd database field as Value variable in Vf page.
<apex:selectList value="{! Contact.assign_1_Business_Vertical__c }" multiselect="true" size="5">
How can I prepopulate multiple values in this scenario.
For example - If you have 3 values which are Finance, Marketing and Sales and you want to Finance and Sales to be pre-selected then set the property as shown below.
Contact.assign_1_Business_Vertical__c = 'Finance;Sales';
Hope it helps.
When I do contact.assign_1_Business_Vertical__c = 'Finance'; // It works
BUT contact.assign_1_Business_Vertical__c = 'Finance;Automobile'; // Does not work for me.
https://developer.salesforce.com/forums/?id=906F0000000g28uIAA
You need to convert 'Finance;Automatible' into the following:
List<String> valueList = List<String>();
valueList .add('Finance');
valueList .add('Automatible');
Then you can feed valueList into the multi-select and it will show the pre-populated values! Ack!