I have below page where I can show different records under different sections based on their record type. Now I have to update only those records where User checks checkbox Confirm_Attestation_abv__c and leave rest. Can someone please guide me here?

Apex page snippet for a particular section:

  <style type="text/css">
    <apex:outputText rendered=" {!Compliance_Incident_Transaction_abv__c.Outcome_abv__c} = -1"></apex:outputText>
    <apex:pageBlock title="Compliance Incident Details for {!Compliance_Incident_Transaction_abv__c.Owner.Name}" id="pb1"  >
        <apex:form >
            <apex:commandButton value="Back" action="{!cancel}" reRender=""/>
        <apex:pageMessages id="pms" />
        <apex:outputpanel id="pmem">
            <apex:PageMessage severity="Error" rendered="{!oInc.Outcome_abv__c !=null}">There are open transactions for which an outcome has not been selected.</apex:PageMessage>
        <apex:pageBlockSection id="coachingsection" title="Coaching Information" columns="1" rendered="{!oInc.Outcome_abv__c == null && Compliance_Incident_Transaction_abv__c.Confirm_Attestation_abv__c == true}">
            <apex:form >
                <apex:outputText >Coaching is already completed for this Incident.</apex:outputText>
                <b>Coached By: </b>
                <apex:outputField value="{!Compliance_Incident_Transaction_abv__c.Attested_By_abv__c}" />
                <b>Submitted Date: </b>
                <apex:outputField value="{!Compliance_Incident_Transaction_abv__c.Attested_Datetime_abv__c}" label="Submitted Date"/>
        <apex:pageBlockSection id="confirmSection" title="Confirm" columns="1" rendered="{!oInc.Outcome_abv__c == null && Compliance_Incident_Transaction_abv__c.Confirm_Attestation_abv__c == false}">
            <apex:form >
                <apex:outputText >By Clicking on Submit button, I acknowledge that I have monitored and completed the required assessment form for the assigned sales representative/field representative.</apex:outputText>

                <apex:commandButton value="Submit" action="{!confirmAttest}" reRender=""/>
<apex:outputPanel layout="none" rendered="{!IF(oIncTranListHCPSpeaker.size>0, true, false)}">
                <apex:tabPanel >
                    <apex:tab label="Speaker Program Attendees" >
                        <apex:pageBlockTable id="Speaker" columns="9" value="{!oIncTranListHCPSpeaker }" border="true" var="itr3" cellPadding="4" >
                        <apex:column headerValue="Coach">
                            <apex:inputField value="{!Compliance_Incident_Transaction_abv__c.Confirm_Attestation_abv__c}"/></apex:column>

                            <apex:column headerValue="Incident ID ">
                                <apex:outputLink value="/{!itr3.Id}">{!itr3.Name}</apex:outputLink>
                            <apex:column value="{!itr3.Account_abv__c}"/>
                            <!--  <apex:column value="{!itr3.Call_abv__c}"/>              -->
                            <apex:column value="{!itr3.Product_abv__c}"/>
                            <apex:column value="{!itr3.Time_of_Event_ABS_abv__c}"/>
                            <apex:column value="{!itr3.Audit_Reason_abv__c}"/>
                            <apex:column headerValue="Transaction Type" value="{!itr3.Recordtype.name}"/>
                            <apex:column headerValue="Outcome" >
                                <apex:actionRegion >                                    
                                    <apex:actionStatus id="SaveStatus">
                                        <apex:facet name="start"  >                                            
                                            <apex:outputText value="Saving...!" />
                                        <apex:facet name="stop"  >
                                            <apex:image url="/img/msg_icons/confirm16.png" title="Saved Successfully" rendered="{!itr3.Id == targetId}" />
                                    <apex:inputField value="{!itr3.Outcome_abv__c}" onchange="jsCallSave('{!itr3.Id}','{!itr3.Recordtype.name}');"  rendered="{!itr3.Confirm_Attestation_abv__c == false}">
                                    <apex:inputField label="Transaction Type" value="{!itr3.Recordtype.name}" style="display:none;"/>
                                <apex:outputField value="{!itr3.Outcome_abv__c}" rendered="{!itr3.Confirm_Attestation_abv__c == true}"/>

Controller snippet: // This method runs on click on Submit button

public PageReference confirmAttest() {//Called from Submit

       for(Compliance_Incident_Transaction_abv__c oInc : oIncListy)
        if (oIncListy.size() == 0) {

            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Incident is not available');


        } else { 
       for(Compliance_Incident_Transaction_abv__c o : oIncListy)

            o.Attested_Datetime_abv__c = DateTime.Now();

            o.Attested_By_abv__c = UserInfo.getUserId();

            o.Status_abv__c = 'Closed';
            o.Confirm_Attestation_abv__c =Attest;//Stamp Confirm_Attestation_abv__c 


            update oIncListy;


catch( Exception x)
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Please try again after changing outcome');


            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.INFO, 'Successfully Attested');



        return null;


enter image description here


You can do one thing create a for loop for checking that how many records in the collection have Confirm_Attestation_abv__c field is checked on, and create a new collection for that and just run update DML operation for new collection. But when you fetch these records again the value of Confirm_Attestation_abv__c field will be already set so you need to uncheck them before performing the operation again.

| improve this answer | |
  • But I am not able to reflect user entry for the checkbox in controller. Even the checkbox is checked once, the page reloads and shows it as unchecked – Testing_SFDC Jul 6 '15 at 8:51
  • You are calling a method "jsCallSave('{!itr3.Id}','{!itr3.Recordtype.name}');" on onchange of checkbox field thats why your page gets reload. – Amit Chaudhary Jul 6 '15 at 9:20
  • How Can I restrict that reload although use jsCallSave. I just want that section to reload . – Testing_SFDC Jul 6 '15 at 9:53
  • 2
    you can do one thing create a apex:actionfunction named as "jsCallSave" and you can use rerender attribute for reloading particular section by specifying component id, and by using action attribute of actionfunction you can call also JavaScript method. – Amit Chaudhary Jul 6 '15 at 10:02

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.