How to Set Default Value for Date Field in Salesforce

The default value for the date field in Salesforce is the initial value that the date field will have when we create the new record.

In this Salesforce tutorial, we will learn how to set the default value for the date field in Salesforce.

For learning this process you have come to the right place and we learned this topic in both the editions of Salesforce Lightning and Salesforce Classic.

How to set the default value for the date field in Salesforce Lightning

Here we will learn how to set the default value for the date field in Salesforce Lightning. Let us take a real-life example, suppose there is an organization where we want to set the default close date for the new opportunity to be 15 days from the current date.

this default value for the close date helps the sales representative have a standard default value when creating a new opportunity. When a user creates a new opportunity with this type of record, the close date will default to 15 days from the current date.

This make sure regularity in our sales process and it also reduces the chances of human error in entering the default close date.

Here are the following steps

1. Open the Salesforce lightning version. After that click on the gear icon that is present at the top right corner, and then click on the Setup option. Under the gear icon, this setup option is present, and the setup page is open.

2. Under this Setup page there is the Object Manager tab present click on the object manager tab. Select the opportunity object, under this opportunity page, we can see the details related to the opportunity object.

How to set the default value for the date field in Salesforce

3. On the left side under the detail section of the opportunity object page, we can see the Fields and Relationships option is present. Click on the Fields and Relationship option. We can see lots of fields are already created but we want to create a new field.

4. So click on the new button, our data types page is open and we can see lots of data types are present here we select the email field and then click on the next button. Our opportunity page is open.

5. Under this page we can see the information related to the opportunity fill in all the information carefully. First, fill in the field label as Close Date and then fill in the field name.

6. After that we scroll to the bottom of the page there is a default value field present here we want to set the default value for this close date field TODAY() + 15 and then click on the next button. This TODAY() function is used in the date datatype field.

Set the default value for the date field in Salesforce

7. After filling in the complete information, now we move to our next step which is to establish field-level security that can select the profiles to which we want to grant edit access to this field via field-level security.

See also  How to Create Master-Detail Relationship in Salesforce

8. The field will be hidden from all the profiles if we do not add it to field-level security and then click on the next button.

Set the default value for the date field in Salesforce Lightning

9. After establishing the field-level security we want to add this field to the page layout. Select the page layouts that should involve this field. This field will be added as the last field in the first 2-column section of these page layouts.

10. The field will not appear on any pages if we do not select a layout. To change the location of this field on the page, we will need to customize the page layout and then click on the save button.

Salesforce set the default value for the date field

11. After clicking on the save button we come back to our field and relationship page. Here we can see our close date field is created and it is a date data type.

12. Click on the App Launcher, click on app launcher, and enter the sales in the search box. The sales come at the top, click on the sales option. The Sales page is open. Under this Sales page, there are lots of objects present on the nav bar and we are selecting one of the objects.

13. Here we are selecting the opportunity object. The opportunity object record page is open. We can see the records are already created. Here we we are creating a new record so we click on the new button. 

14. We can see the records are already created. Here we we are creating a new record so we click on the new button. First, fill in the opportunity name then fill in the type, and then fill in the lead source.

15. After that fill in the time duration and then fill the amount and then fill the stage, and then fill the discount percentage, and fill in the annual revenue then we can see over close date is by default field and this shows the close date to be 15 days from the current date and then we click on the save button.

Salesforce Lightning set the default value for the date field

16. After filling in the information related to the opportunity object, our opportunity record salesforce opportunity is created and our salesforce opportunity detail page is open under this page, we can see our default value which is the close date of opportunity is set to be 15 days from the current date.

How to set default value for the date field in Salesforce

In this way, we understand how to set the default value for the date field in Salesforce Lightning. Let’s Proceed further and learn how to set the default value for the date field in Salesforce Classic.

How to set the default value for the date field in Salesforce Classic

Here we will learn how to set the default value for the date field in Salesforce Classic. So let us take an example, there is a salesforce organization and they have a custom object called project with two date fields.

The first date field is a Start date and the second date field is the end date for this we want to set the default value for the end date field that is based on the start date field but the user needs to enter the current day on which day they are working and a predefined duration for the project.

See also  Currency field with Default Value in Salesforce

When a user creates a new project and enters a start date, the current date end date will automatically default to 30 days later. This is efficient data entry and makes sure of regularity in how project duration is calculated.

Here are the following steps

1. Our Salesforce Lightning account is open when we login into salesforce, but we want to work on the Salesforce Classic version. For this click on the profile picture, under this profile picture, there is an option to switch to a Salesforce classic account.

2. Click on the switch to a Salesforce Classic, Our Salesforce Classic org is open. Under this Salesforce Classic org, we can see that the username is present. Click on the drop-down arrow of the username.

3. Our drop-down list is open. Under this drop-down list, we can see that the Setup option is present. Click on the Setup page. Under this setup page, we can see on the left side there is Quick Find box is present.

4. Enter the objects in the Quick Find box and our custom object page is open. Here we can see lots of objects are present and we are selecting the project object. Our project object page is open.

How to set the default value for the date field in Salesforce Classic

5. Here we can see the details related to the project and then scroll to the bottom we can see there is a project custom fields and relationships section. Under this section, we can see that the Start date field is already created and present under the field and relationship section.

Set the default value for the date field in Salesforce Classic

6. But there is no end date field present so we want to create a new field. So click on the new button. Our data type page is open and under this page, we can see lots of data types are present here we select the date field and then click on the next button.

7. After clicking on the data type our project information page is open, under this page we can see the information related to the project fill information carefully.

8. First fill the field label as End Date and then fill in the field name after that we scroll to the bottom of the page there is a default value field present here we want to set the default value for the End Date and time field TODAY() + 30 and then click on the next button.

Salesforce Classic set the default value for the date field

9. After filling in the complete information, now we move to establish field-level security that can select the profiles to which we want to grant edit access to this field via field-level security.

10. The field will be hidden from all the profiles if we do not add it to field-level security and then click on the next button. After establishing the field-level security we want to add this field to the page layout.

See also  How to Change the Values Displayed in Lookup Field in Salesforce?

11. Select the page layouts that should involve this field. This field will be added as the last field in the first 2-column section of these page layouts. The field will not appear on any pages if we do not select a layout.

How to set default value for the date field in Salesforce Classic

12. The field will not appear on any pages if we do not select a layout. To change the location of this field on the page, we will need to customize the page layout and then click on the save button.

Set default value for the date field in Salesforce Classic

13. Go to the home tab, and under this home tab, we can see lots of tabs are present on the nav bar. Here we are selecting the task object from the nav bar, the project object page is open and under this object, we can see the records are present that are already present.

14. Here we are creating a new record so we click on the new button. The new project page is open and under this page, we can see the information related to the project.

15. First, fill in the Project name as Salesforce Project then fill in the Project Status, and then fill in the Project task start after that fill in the Project Completion and then fill the project completion percentage and then fill the task estimated hours.

16. After that fill the start date which is the current date and then we can see the end date is 30 days from the current date and then click on the save button.

Salesforce Classic set default value for the date field

17. After filling all the project information, our project details related to the salesforce project is created and shown under the salesforce project page. Here we can see that our end date is 30 days from the current day.

18. We can also edit, delete, clone, and share this salesforce record by simply clicking on the button.

How to set a default value for the date field in Salesforce Classic

So with this, we understand how to set the default value for the date field in Salesforce Classic.

Conclusion:

I hope you read the complete article and get the complete idea related to how to set the default value for the date and time field in Salesforce.  I have also explained all the steps of setting the default value for the date and time field in Salesforce Lightning and Salesforce Classic.

You may like to read