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
Sonya Dhand 3Sonya Dhand 3 

Visual Force page will not Save changes

Hi 

I have a visual force page for a custom object and is in in line edit mode and has 2 buttons one to Save and one to Cancel.  The problem is I can edit my page and click save and the changes stay on the page but when i refresh the whole page the changes do not save

Here is my code
 
<apex:page cache="false" standardController="Employee__c" tabStyle="Employee__c" showHeader="false" sidebar="false">
    <apex:form id="all" >
        <apex:pageMessages />
     
        <apex:pageBlock title="Worker Licence Record Section" mode="inlineEdit">
     
        
           <apex:pageBlock mode="maindetail">
           
           
           

           
            <apex:pageBlockButtons location="top">
                
             
                
                <button onclick="location.href='/apex/Worker_Section?id={!Employee__c.Id }'" id="saveButton">
                    Save
                </button>
                
                <button onclick="location.href='/apex/Worker_Section?id={!Employee__c.Id }'" id="cancelButton">
                    Cancel
                </button>
                
            </apex:pageBlockButtons>
            <style>
                     .bPageBlock {
                                background-color: white !important;
                     }
                     
                     .pbHeader{

        color:grey;

        width:100%;

        font-size:90%;

        }

               </style>
               
               
            
            
            <apex:outputPanel styleClass="white" layout="block">
                
                <apex:pageBlockSection collapsible="true" columns="3">
                
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >SIA Licence Type</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.SIA_LICENCE__c}" style="width:80px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >SIA Licence #</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.Licence_No__c}" style="width:125px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >Expiry Date</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.Expiry__c}" style="width:100px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >CSCS Card?</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CSCS_Card__c}" style="width:80px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >CSCS Licence #</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CSCS__c}" style="width:125px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%" >
                        <apex:outputLabel >Expiry Date</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CSCS_Expiry_Date__c}" style="width:100px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >CCTV Licence?</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CCTV_Licence_Type__c}" style="width:80px"/>
                    </apex:pageBlockSectionItem>
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%" >
                        <apex:outputLabel >CCTV Licence #</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CCTV_Licence__c}" style="width:125px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >Expiry Date</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.CCTV_Expiry__c}" style="width:100px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%" >
                        <apex:outputLabel >Driving Licence?</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.Driving_Licence__c}" style="width:80px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%" >
                        <apex:outputLabel >Driving Licence #</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.Driving_Licence_Number__c}" style="width:125px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    <apex:pageBlockSectionItem dataStyle="width:10%" labelStyle="width:23%"  >
                        <apex:outputLabel >Expiry Date</apex:outputLabel>
                        <apex:inputField value="{!Employee__c.Driving_Licence_Expiry__c}" style="width:100px"/>
                    </apex:pageBlockSectionItem>
                    
                    
                    
                    
                </apex:pageBlockSection>
            </apex:outputPanel>
            
            </apex:pageBlock>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Does anyone have any ideas?

Thanks

Sonya 
 
Mario BravoMario Bravo
Hi, Sonya
You're not adding the Save action to the button. Besides, it's best when you use <apex:commandButton> instead of <button>, within the <apex:pageBlockButtons>.
Try with the following snippet:
<apex:pageBlockButtons location="top">
                          
                
                <apex:commandButton action={!quicksave} onclick="location.href='/apex/Worker_Section?id={!Employee__c.Id }'" id="saveButton" value="Save"/>
                  
                
                <apex:commandButton action={!cancel} onclick="location.href='/apex/Worker_Section?id={!Employee__c.Id }'" id="cancelButton"/>
                    
                
                
</apex:pageBlockButtons>

Regards,

Mario
 
Mario BravoMario Bravo
I forgot something...just add value="Cancel" to de cancel button definition.
<apex:commandButton action={!cancel} onclick="location.href='/apex/Worker_Section?id={!Employee__c.Id }'" id="cancelButton"/ value="Cancel">