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
Kiran kumar 193Kiran kumar 193 

Multiselect Picklist Stroring Previous value if current record value is null (Button on Case List page)

I am trying to update the field values from Buttion click on case list page. Button invoking VF page to display the Picklist Dependent fields. We have three fields to update for multiple records.

Type (Pick list) -Required
Subtype (picklist) - Required
Totalsubtype(Multiselect Picklist) - Not required

First two fileds are updating correctly but Multi select picklist is storing previous value if the current record value is null when try to update the records. If there is no value in the multiselect field I need to update as blank.

Please suggest the solution... I need it urgently
Controller :
public class CaseUpdate
{
   private final List<Case> cases;
   public boolean isErrorOccured{get;set;} 
           
   public ESDJC_CaseUpdate(ApexPages.StandardSetController standardController)
   {
      
     this.cases = [select Id,Topic__c,RecordType.Name,Sub_Topic__c,Type from case where id in : standardController.getSelected()];
     
    
   }
   public PageReference cancel(){
        PageReference returnPage = new PageReference(ApexPages.currentPage().getParameters().get('retURL'));
        return returnPage;
    }
    public PageReference validateOnLoad(){
    
         if(cases == null || cases.size() == 0 ){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one record.'));
            isErrorOccured = true;
            
            return null;
        }
        
       
      return null;  
   }
  
  
   }
 
VF page:

<apex:page standardController="Case" recordSetVar="Cases" extensions="CaseUpdate" action="{!validateOnLoad}">
<html xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">  
        <head>
            <apex:stylesheet value="{!URLFOR($Resource.SLDS090, 'assets/styles/salesforce-lightning-design-system-vf.css')}" />
        </head>
     <body>     
    <div class="slds">
    <apex:form id="theForm" >
  <apex:pageMessages id="messages"/>
        <apex:pageBlock mode="edit" id="pb">
            <apex:pageBlockButtons >
                <apex:commandButton styleClass="slds-button slds-button--neutral" action="{!Save}" value="Save" rerender="messages"  rendered="{!!isErrorOccured}"/>
                <apex:commandButton styleClass="slds-button slds-button--neutral" value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="Case Information" columns="1">
            <apex:inputField value="{!Case.Type}"/>
            <apex:inputField value="{!Case.Topic__c}" />
            
            <apex:inputField value="{!Case.Sub_Topic__c}" >
          
           
            </apex:inputField>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    </div>
    </body>
    </html>
</apex:page>
Ajay Ghuge 6Ajay Ghuge 6
Hi ,

Can you remove the rendered in command button and debug again. I guess you will get error on the page.

Regards,
Ajay