Let the platform do the work

Dependent Field - Date Equals Today

Overview

Dependent Fields use Sugar Logic to control the fields' visibility so that they are only shown when certain conditions are met. Administrators can create these formulas via Studio or Module Builder when editing a field by selecting the Dependent checkbox and using the formula builder. 

For an overview on Sugar Logic and Calculated Fields, please refer to the article Introduction to Calculated Fields.

Note: This article pertains to Sugar version 7.

Use Case

In this example, we will display a custom textarea field named "Follow Up Notes" only if the custom date field named "Follow Up Date" is set to today.

Prerequisites

You will first need to create a new field of type Date called "Follow Up Date". Next, create another new field of type TextArea called "Follow Up Notes" and marked as a dependent field with the following formula determining its visibility.

Formula

The Follow Up Notes field with a dependency formula as follows will only appear when the Follow Up Date is today:

equal($followupdate_c, today())

Formula Breakdown

The today() function returns the current day's date. We then use the equal() function to compare the date stored in our custom date field, $followupdate_c, with today's current date. If the two dates match, the equal() formula returns true, and the dependent field will be made visible.

Application

Once your two custom fields are created with the dependency formula and they are added to the module's record view, the dependent field will appear if the date field contains today's date. For our example, the Follow Up Notes field is visible since the Follow Up Date field is set to today's date.