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
Gil HechtGil Hecht 

Populate an InputField with a Default Value?

Hi below is my code for a visualforce page. I'm wondering if in the last_dial__c field I can autopopulated it with today's date as a default value. Thanks!

 

<apex:page standardController="Lead" recordSetVar="leads" tabStyle="Lead" extensions="tenPageSizeExt">
    <apex:form >
        <apex:pageBlock title="Log a Call" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons location="top">
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!selected}" var="leadselect">
               <apex:column headerValue="Lead Name">
                <apex:inputField value="{!leadselect.name}"/> </apex:column>
                   <apex:column headerValue="Number of Dials">
                    <apex:inputField value="{!leadselect.Calls_Made_Counter__c}"/>
                </apex:column>
                <apex:column headerValue="Last Dialed">
                    <apex:inputField value="{!leadselect.Last_Dial__c}"/>
                </apex:column>

            </apex:pageBlockTable>      
        </apex:pageBlock>
    </apex:form>
    </apex:page>
Krishna SambarajuKrishna Sambaraju
Hi,

In the constructor of your extension class, you can set the default value like below.
leadselect.Last_Dial__c = system.today();

Regards,
Krishna.