When changing a multiselect field I am calling a updateLOBlist() method to update a string (multiSelectValues.) However, when deselecting values from the multiselect I am not seeing the string values change. In this example I originally had selected AH, CommercialAuto, GeneralLiability, Homeowners, NonStandardAuto, PersonalAuto but when deselecting the string does not change.

enter image description here

Debug after removing items: AH, CommercialAuto, NonStandardAuto, PersonalAuto

DEBUG|UPDATED LOBS {AH, CommercialAuto, GeneralLiability, Homeowners, NonStandardAuto, PersonalAuto}

  public Set<String> multiselectValues = new Set<String>();

    Public Void updateLOBlist() {                  
      System.debug('UPDATED LOBS ' + multiSelectValues);           
      System.debug('LOB FOUND NONSTDAUTO ');
     }else {
      System.debug('NO LOB FOUND');

Visualforce Page with Multiselect

<apex:pageBlockSectionItem dataStyleClass="col"  >
<apex:actionRegion >                      
 <apex:inputField id="LOB" value="{!Claims_Client_Risk_Assessment__c.Lines_of_Business__c}" styleClass="col2" >
  <apex:actionSupport action="{!updateLOBlist}" event="onchange" reRender="theLOBTabPanel,OutputLOBTabPanel,theLOBTabPanel1" / > 

When your action method executes, you add into the set multiSelectValues the current values of field CCRA.Lines_of_Business__c but ...

you never reset the collection multiSelectValues to empty and hence previous values are still there!

public Set<String> multiselectValues = new Set<String>();

 public Void updateLOBlist() {                  

  • Excellent @cropredy ! Hasty oversight on my part!
    – rickmac
    Jul 28 '18 at 1:09
  • cool; as favor to community, if that works out for you; mark the answer as 'accepted' or post a better answer
    – cropredy
    Jul 28 '18 at 1:13

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.