I am getting an error that I am not able to determine what is the main cause of it, what i am doing is creating a multipicklist into a checkboxes in a VF page. I am getting a weird error message when i try to submit my form:
error message:
Conversion Error setting value 'Travel and Adventure' for '#{selectedPerson_Interest}'.
this happens if i select 1 or more items
vf page code:
<apex:selectCheckboxes value="{!selectedPerson_Interest}" layout="lineDirection">
<apex:selectOptions value="{!Person_Interest}" />
</apex:selectCheckboxes>
controller:
public List<string> selectedPerson_Interest { get; set; }
public List<SelectOption> Person_Interest {
get {
Person_Interest = new List<SelectOption>();
Schema.DescribeFieldResult accountPerson_Interest = Account.Person_Interest__c.getDescribe();
List<Schema.PicklistEntry> accountPerson_InterestValues = accountPerson_Interest.getPicklistValues();
for (Schema.PicklistEntry a : accountPerson_InterestValues) {
Person_Interest.add(new SelectOption(a.getLabel(), a.getValue()));
}
return Person_Interest;
}
set;
}
i think my code looks pretty similar to: Displaying Multiselect Picklist as checkboxes question so i am not sure what i am doing wrong
EDIT:
So it works fine now, I am able to submit the form however I am not able to save the result into the field. This is the new code
public FormMiniFWCController() {
selectedPerson_Interest = new List<string>();
selectedEmail_Subscriptions = new List<string>();
Person_Interest = new List<SelectOption>();
Schema.DescribeFieldResult accountPerson_Interest = Account.Person_Interest__c.getDescribe();
List<Schema.PicklistEntry> accountPerson_InterestValues = accountPerson_Interest.getPicklistValues();
for (Schema.PicklistEntry a : accountPerson_InterestValues) {
Person_Interest.add(new SelectOption(a.getLabel(), a.getValue()));
}
Email_Subscriptions = new List<SelectOption>();
Schema.DescribeFieldResult accountEmail_Subscriptions = Account.Email_Subscriptions__c.getDescribe();
List<Schema.PicklistEntry> accountEmail_SubscriptionsValues = accountEmail_Subscriptions.getPicklistValues();
for (Schema.PicklistEntry a : accountEmail_SubscriptionsValues) {
Email_Subscriptions.add(new SelectOption(a.getLabel(), a.getValue()));
}
}
public String[] selectedEmail_Subscriptions { get; set; }
public SelectOption[] Email_Subscriptions { get; set; }
public String[] selectedPerson_Interest { get; set; }
public SelectOption[] Person_Interest { get; set; }
and this is the section where i am trying to save it:
Account acct = new Account(
.......
Person_Interest__c = selectedPerson_Interest,
Email_Subscriptions__c = selectedEmail_Subscriptions
);
insert acct;
the error message that I get is Invalid initial expression type for field Account.Person_Interest__c, expecting: String
so i try to transform that list into a string and submitted however, if i go to the account and i try to modify the value, the value is save as a whole string and not as an options
selectedPerson_Interest
in constructor asselectedPerson_Interest = new List<string>();