How to Set Default Value for Date and Time Field in Salesforce

In Salesforce, the default value refers to the pre-defined value that is assigned to the date and time field when a new record is created. Default values help smooth data entry and save time for users.

In this Salesforce tutorial, we will learn how to set the default value for the date and time 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 and time field in Salesforce Lightning

Here we will learn how to set the default value for the date and time field in Salesforce Lightning.

Let us take an example to clear our scenario, suppose there is a company that uses the salesforce to manage their work and I am working in this company as an employee. It’s my duty to set the close date for an opportunity as a default value.

In the salesforce, there is a custom object opportunity is present select the opportunity object, and inside this opportunity object we make the custom field or select the already created custom field like closed date and set the default value for it.

Here we are entering the formula for the default value like we might set the default closed date to be 30 days from the current date.

Here are the following steps

1. Click on the Salesforce account and our Salesforce lightning version is open. We set the default value for an email field. For this, we can click on the gear icon that is present at the top right corner, and then click on the Setup option.

2. Under the gear icon this setup option is present, and the setup page is open, Under this Setup page there is the Object Manager tab present click on the object manager tab. The Object Manager page opens, after clicking on the Object Manager tab.

3. Under this opportunity page, we can see the details related to the opportunity object. 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.

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

4. We can see lots of fields are already created but we want to create a new field. 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 date and time field and then click on the next button.

5. Our opportunity page is open, under this page we can see the information related to the opportunity fill in all the information carefully.

6. First, fill in the field label as Closed 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 this closed date field “NOW() + 30” and then click on the next button.

See also  Salesforce Case Sensitivity For Text Field Type
How to set the default value for the date and time field in Salesforce Lightning

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.

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. After establishing the field-level security we want to add this field to the page layout.

9. 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.

Set the default value for the date and time field in Salesforce

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.

Set the default value for the date and time field in Salesforce Lightning

11. 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.

12. Under this Sales page, there are lots of objects present on the nav bar and we are selecting one of the objects. If the object is not shown on the nav bar click on the More drop-down arrow.

13. But our opportunity object is shown on the nav bar, click on 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. 

15. First, fill in the opportunity name then fill in the type, and then fill in the lead source 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 show the closed date to be 30 days from the current date and then we click on the save button.

Salesforce set the default value for the date and time 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 closed date of opportunity is set to closed date to be 30 days from the current date.

Salesforce Lightning set the default value for the date and time field

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

See also  Configure Dashboard Data Visibility in Salesforce

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

Here we will learn how to set the default value for the date and time field in Salesforce Classic. Let’s take an example, imagine there is a company that creates products and uses salesforce and I am the employee working in this company. Our manager gives us the task and it takes us one week from the current date and time.

The task date and time value are set by default for this they choose the custom object called to task and under this custom object there is a custom date time field for creating a new field here we create a new field which is the due date and time.

We want to set the default due date and time for the new records to be one week from the current date and time.

Here are the following steps

1. Click on the Salesforce account, our Salesforce Lightning account is open but we want to move to 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. Select the Setup option. The Setup page is open. 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. Select the object option and our custom object page is open. Here we can see lots of objects are present and we are selecting the task object. Our task object page is open.

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

5. Here we can see the details related to the event and then scroll to the bottom we can see there is a task custom fields and relationships section. Under this section, we can see that already created fields are present but we want to create a new field for the task and set the default value for the due date and time field in Salesforce.

6. Our data type page is open and under this page, we can see lots of data types are present here we select the due date and time field and then click on the next button.

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

9. First fill the field label as due date and time 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 due date and time field “NOW() + 7” and then click on the next button.

Set the default value for the date and time field in Salesforce Classic

10. 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.

See also  Salesforce Phone Data Type

11. 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.

12. 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.

Salesforce Classic set the default value for the date and time field

13. 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.

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

14. 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 task object page is open and under this object, we can see the records are present that are already present.

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

16. First, fill in the task name as salesforce task then fill in the checkbox checked date, and then fill in the task description as this is a salesforce task after that fill in the due date and time and then click on the save button.

Set default value for the date and time field in Salesforce Classic

So with this, we understand how to set the default value for the date and time 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