0

I had a line item with a multiselect feature. It was working and saving fine but without any code change all the sudden it does not save correctly, if I select 3 items it only highlights two items and so on. Not sure why, is this a known bug of some sorts, where should I check to find the problem?

VF

 <apex:SelectList rendered="{!contains(di.dataType, 'Multipicklist')}" size="5" value=" 
                                                 {!di.multiSelect}" multiselect="true">
         <apex:SelectOptions value="{!di.pickList}" />
 </apex:SelectList> 

Apex

 public String[] multiSelect {get; set;}

Method used to create the list options, which works

 private List<SelectOption> createLists(string content) {
        List<SelectOption> pickList = new List<SelectOption>();   
        List<String> options = content.split(';');             

        for (String value : options) 
            pickList.add(new SelectOption(value, value));   

        return pickList;  
    } 



 if ( dataType.equals('Multipicklist')) {
    //content is the list of selection options retrieved from another object.
            object.pickList = createLists(content);
    }

These are code snippets of the relevant parts and it is fairly safe to assume the other components are working.

If anyone can offer suggestions it would be greatly appreciated. This link kind of illustrates my bug as well: https://success.salesforce.com/issues_view?id=a1p30000000T21lAAC //additional comments on Save

Stores the selected values in Value__c

When I load them again after save and refresh I use this code:

//Iterates through each line item
public String[] multiSelect {get; set;} // stores the selected multiselect values
//

if (datatype = 'Multipicklist')
{       
        //value__c is the salesforce field where I store my selected values.
        subClassObject.multiSelect = salesforceObject.Value__C.split(';');

}
15
  • 2
    Your question is a little unclear. Please post your code so we can help. Commented Apr 23, 2014 at 17:46
  • added more details
    – ths
    Commented Apr 23, 2014 at 17:58
  • By "highlight" do you mean that when you click on three, only two move across? Or that three are selected but the controller only saves two options? If that is the case, then please post the method that executes the DML, where you save the value of the List<String> multiSelect to a record. Commented Apr 23, 2014 at 18:08
  • From debugging I noticed that all three values are saved in the controller but only two are highlighted as the selected value once I press save, so when I press save again, it saves two values and only highlights one as selected. This does not happen when I choose any combination which includeds the very first value in my list. So say I my options are 1-5. If I select 2,3,4 they are saved in the controller but only 3,4 are highlighted after the save.
    – ths
    Commented Apr 23, 2014 at 18:16
  • 1
    This sounds like it might be a problem with how you are processing the picklist. when you say "3 values are saved in the controller" not sure what that means. If you debug the select list values at the time you save, are the 3 selected values still in the variable? How are you converting them back to the ; delimited value for saving, and how are you parsing the "existing record" again after the save to get the selected values?
    – JimRae
    Commented Apr 25, 2014 at 20:27

0

You must log in to answer this question.

Browse other questions tagged .