I am trying to make a VF page that updates a custom object called Time_Sheet__c

I only need a Text box and a save button (that updates the already existing Time sheet)

The problem i am having with my VF page is that it creates a new record rather than updating the Note_for_the_day__c field in the existing record

Here is my VF page so far:

    <apex:page standardController="Time_Sheet__c">
width: 400px;}</style>
<apex:form >
  <apex:Pageblock Title="Notes on the Day">
  <apex:pageBlockSection columns="1">
  <apex:pageBlockSectionItem >
  <apex:outputLabel ></apex:outputLabel>  
  <apex:inputField Value="{!Time_Sheet__c.Note_for_the_Day__c}"
  <apex:commandButton action="{!save}" value="save"/>




What do I have to change to fix this issue?


Here is the Clock in and Out VF page that creates the record i want to update. Maybe we can just add the text box and update button to this VF page?

<apex:page controller="AttendanceController" id="thePage" >
<apex:stylesheet value="{!URLFOR($Resource.slds120,'assets/styles/salesforce-lightning-design-system.css')}"/> 
<apex:form id="theForm">
    <apex:inputhidden id="location" value="{!location}"/><br/>
    <article class="slds-card slds-card--narrow">
        <div class="slds-card__header slds-grid">    
            <div class="slds-card__body" >
                <div class="slds-tile__detail slds-text-body--small" >
                            <span class="slds-text-heading--small">Today's Time Sheet</span>                            
                    <dl class="slds-dl--horizontal" >       

                        <apex:repeat value="{!currUserTimeSheetLst}" var="userTimeSheet">
                             <dt class="slds-dl--horizontal__label" style="display:{!IF(userTimeSheet.Clock_in__c != Null ,'block','None')}">
                            <span class="slds-truncate" title="Checked_In_Time">Checked In Time : <apex:outputfield value="{!userTimeSheet.Clock_in__c }"/></span>
                        <dt class="slds-dl--horizontal__label" style="display:{!IF(userTimeSheet.Clock_Out__c != Null ,'block','None')}">
                            <span class="slds-truncate" title="Checked_Out_Time">Checked Out Time : <apex:outputfield value="{!userTimeSheet.Clock_Out__c }"/></span>

        <div class="slds-card__body" >                  
            <apex:commandlink styleClass="slds-button slds-button--neutral" action="{!checkIn}" value="Check In" style="display:{!IF(currUserTimeSheet.Clock_in__c == Null ,'block','None')} "/>
            <apex:commandlink id="CheckOut" styleClass="slds-button slds-button--neutral" action="{!checkOut}" value="Check out" onclick="if(!confirm('Are you sure to Check out?')){return false};" style="display:{!IF(currUserTimeSheet.Clock_in__c != Null && currUserTimeSheet.Clock_Out__c == Null,'block','None')} " />                
<script type="text/javascript">    
//error handler
function showError(error) { 
    var strError = "Unknown Error";
    switch(error.code) {
        case error.PERMISSION_DENIED:
            strError = "User denied the request for Geolocation."
        case error.POSITION_UNAVAILABLE:
            strError = "Location information is unavailable."
        case error.TIMEOUT:
            strError = "The request to get user location timed out."
        case error.UNKNOWN_ERROR:
            strError = "An unknown error occurred."
    document.getElementById("thePage:theForm:location").value  = strError;

//success handler
function successGeo(position){        
    lat = position.coords.latitude;
    lon = position.coords.longitude;        
    var strLatLong = + lat.toString() + ',' + lon.toString();
    document.getElementById("thePage:theForm:location").value  = strLatLong;
// detection capabilities with JavaScript    
if (navigator.geolocation) {
    //alert('Getting Geolocation');        
    navigator.geolocation.getCurrentPosition(successGeo, showError);

  • How are you navigating to this page? – Adrian Larson Mar 17 '17 at 17:17
  • Adrian, I just made an edit and added the code that holds the Check in and out buttons that create the record. Maybe this will help you. I can also post the class if youd like. I am just unsure what you mean by "navigating to this page". It is just a Tab in our Lightning that we put VF components into – Alex Waddell Mar 17 '17 at 17:22

If there is no Id specified, the standard controller assumes an insert operation. If you want to supply an Id for update, use the Id parameter.


Replace the placeholder values in angle brackets (<>) with actual values from your org.

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.