Add relationship start date logic to the existing Civi scheduled job for relationships
Overview
If a user creates a relationships with a future start date:
- The relationship shows in the ‘active’ relationships section
- is_active field of the relationship is set as 1
As CiviCRM treats this as an ‘active relationship’, so does webform_civicrm, which means users can select a contact with this relationship (through setting the existing contact field show contacts with this relationship) even if the start date is in the future
Example use-case
- Go to a contact
- Add a relationship with start date in future ie start date > today (and no end date)
- Save relationship
- is_active field for the relationship (check civicrm_relationship table) is set to 1
Current behaviour
On creation / updating of a relationship with a future start date (start date>today), CiviCRM sets the is_active field = 1
Proposed behaviour
On creation / updating of a relationship with a future start date (start date>today):
- SET is_active =0
Add to the logic of the existing relationship expiry scheduled job (Disable expired relationships) which sets the is_active field to 0 for relationships where end date is in the past:
-
Update 'Title' to: Enable and Disable relationships
-
Help text: Enables relationships where start date < = today (ie those relationships whose start date is today / in the past) Disables relationships that have expired (ie. those relationships whose end date is in the past).
-
Logic: Along with the existing logic (for disabling expired relationships), we are adding the following logic to the same scheduled job: Sets the relationship is_active field = 1 for relationships where start date < = today AND end date >today (ie those relationships whose start date is today / in the past)