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
aamDevaamDev 

Conversion Error setting value from Multi Select List

I have two multi select lists that I pass values back and forth using jQuery. When testing the values that are being passed from both lists, I receive "Conversion Error setting value" with the values from the select lists with spaces in between:

 

Conversion Error setting value 'a0BQ0000000y4KRMAY a0BQ0000000y4LAMAY' for '#{productionNumbers}'.
Conversion Error setting value 'a0BQ0000000y4LFMAY' for '#{selectedNumbers}'.

 

I need these values to run some SOQL queries and subsequent updates.   More specifically, these values (ids) will be used in:

 

Set<Id> newAvailable = new Set<Id>();
		
for (Production_No__c submitAvailable : [SELECT Id FROM Production_No__c WHERE Id IN : productionNumbers]) {
			
	newAvailable.add(submitAvailable.Id);
			
}


Set<Id> newSelected = new Set<Id>();
		
for (Production_No__c submitSelected : [SELECT Id FROM Production_No__c WHERE Id IN : selectedNumbers]) {
			
	newSelected.add(submitSelected.Id);
			
}

 

 

Here's their properties in the class:

 

public String[] productionNumbers {
		
	get; set;
		
}

public String[] selectedNumbers {
		
	get; set;
		
}

 

 

In the VF page, they're represented by:

 

<apex:selectList id="productionNumbers" styleClass="firstSelect" value="{!productionNumbers}" multiselect="true" size="4">
	<apex:selectOptions value="{!productionOptions}" />
</apex:selectList>


<apex:selectList id="selectedNumbers" styleClass="secondSelect" value="{!selectedNumbers}" multiselect="true" size="4">
	<apex:selectOptions value="{!selectedOptions}" />
</apex:selectList>

 

 

How do I go about retrieving this values for use in my loops? Thanks.

Best Answer chosen by Admin (Salesforce Developers) 
XactiumBenXactiumBen

In your constructor, you need to initialise the list variables that you are using.  e.g.:

 

public class myController
{
public myController()
{
productionNumbers = new String[] {};
}
}

 

All Answers

XactiumBenXactiumBen

In your constructor, you need to initialise the list variables that you are using.  e.g.:

 

public class myController
{
public myController()
{
productionNumbers = new String[] {};
}
}

 

This was selected as the best answer
aamDevaamDev

Thanks, that worked perfectly. Unfortunately, I'm now receving a "Validation Error: Value is not valid" message after passing options between lists. This is extremely frustrating, especially since I saw that I was passing the correct values between the lists before the conversion error issue. Any idea on why I'm receiving this now?

 

Thanks again for all your help, it is very much appreciated.