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
Simon BairdSimon Baird 

Mass-Updating Records with a Custom List Controller

I am using the code from the developer pages to mass update records from a list view. It works great in most instances except when it comes to checkbox fields. If I mass update records and check a checkbox field then update them again but update a different field it unchecks the previously checked boxes. None of the other fields on the page get updated unless they have new data inserted just seems to be with the checkbox fields. I am assuming it is because it is seeing them as field change but technically they should not be. Has anyone seen this behaviour before?

Here's the VF markup and controller extension i have used
http://www.salesforce.com/docs/developer/pages/Content/pages_compref_inputField.htm
Simon BairdSimon Baird
VF Markup
<apex:page standardController="Patient_Session__c"
    recordSetVar="progressnotes"
    extensions="selectedSizeWorkaround"
    showHeader="true"
    sidebar="false"
    id="mupgn"
>
<style type="text/css">
        .myClass { width: 450px; }
    </style>
    
    <apex:form id="muform">
        <apex:pageMessage summary="Selected Collection Size: {!mySelectedSize}" 
            severity="info"
            id="mupms"
        />
       
        <apex:pageBlock title="Mass Update Progress Notes" mode="edit" id="mub1">
            <apex:pageMessages />
            <apex:pageBlockSection title="Treatment Information" id="mus1">
                <apex:inputField value="{!Patient_Session__c.Treated__c}" id="Treated__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Reason_nottreated__c}" id="Reason_nottreated__c" required="true">
                </apex:inputField>                
                <apex:inputField styleClass="myClass" value="{!Patient_Session__c.Treatment_Notes__c}" id="Treatment_Notes__c">
                </apex:inputField>                                           
                <apex:inputcheckbox value="{!Patient_Session__c.Override_Auto_Notes__c}" id="Override_Auto_Notes__c">
                </apex:inputcheckbox>
                <apex:pageBlockSectionItem > </apex:pageBlockSectionItem> 
                <apex:inputcheckbox value="{!Patient_Session__c.NCP__c}" id="NCP__c">
                </apex:inputcheckbox>
                <apex:inputField value="{!Patient_Session__c.Treatment_Type__c}" id="Treatment_Type__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Date_of_Treatment__c}" id="Date_of_Treatment__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Receipt_Number__c}" id="Receipt_Number__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Receipt_entered__c}" id="Receipt_entered__c">
                </apex:inputField>                 
                <apex:inputField value="{!Patient_Session__c.Completed_EPC_DVA_Vouch__c}" id="Completed_EPC_DVA_Vouch__c">
                </apex:inputField>
                <apex:inputcheckbox value="{!Patient_Session__c.Deduct_Cash_from_Pay__c}" id="Deduct_Cash_from_Pay__c" rendered="{!Patient_Session__c.Deduct_Cash_from_Pay__c!=true}"> 
                </apex:inputcheckbox> 
                <apex:inputField styleClass="myClass" value="{!Patient_Session__c.Message_for_AFC_office_re_Patient__c}" id="Message_for_AFC_office_re_Patient__c">
                </apex:inputField>               
                </apex:pageBlockSection>
                
                <apex:pageBlockSection title="Sterilisation Information" id="mus2">
                <apex:inputField value="{!Patient_Session__c.Sterile_Pack_1__c}" id="Sterile_Pack_1__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Load_Number__c}" id="Load_Number__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Sterile_Pack_2__c}" id="Sterile_Pack_2__c">
                </apex:inputField>
                <apex:inputField value="{!Patient_Session__c.Load_Number_2__c}" id="Load_Number_2__c">
                </apex:inputField>                 
                </apex:pageBlockSection>
                
            <apex:pageBlockButtons id="mubut">
                <apex:commandButton value="Save" action="{!save}" id="butsav"/>
                <apex:commandButton value="Cancel" action="{!cancel}" id="butcan"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock title="Selected Progress Notes" id="muselectedlist">
            <apex:pageBlockTable value="{!selected}" var="pgn" id="mutab">
                <apex:column value="{!pgn.Patient__c}" id="oppname"/>
                <apex:column value="{!pgn.Patient_Care_Level__c}" id="oppname2"/>
                </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex Class
public class selectedSizeWorkaround {

    ApexPages.StandardSetController setCon;

    public selectedSizeWorkaround(ApexPages.StandardSetController controller) {
        setCon = controller;
    }

    public integer getMySelectedSize() {
        return setCon.getSelected().size();
    }
    public integer getMyRecordsSize() {
        return setCon.getRecords().size();
    }
}