Starting in SugarCRM 6.2, we can use dates in SugarLogic formulas. This means we can now calculate fields like Due Date without writing custom code.
For example, we can open the “date_due” field of tasks in studio and check the “Calculated Value” checkbox. If we want the date due to be two weeks from the start date, we can use the formula:
Because Date Due is now a calculated field, we can no longer set the value manually in the Edit View. To get around this, we can create a Vardef Extension that set the “enforced” property of the field to false. This will cause Sugar to leave the field editable on Edit Views, but still recalculate the value when other fields are changed. For example, when we modify the Start Date of Tasks, the Date Due will automatically be set to 2 weeks from the Start Date. However, we can now still edit Date Due and set it to an arbitrary value.