Answers.Body: <p>The default action is that the latest employer becomes the active and current employer and the former employer becomes inactive.  This occurs because this is what typically people want to happen.  As a user registering for an event in 2017, I put my employer as Alphabet, but in 2019, I register for an event, and put my employer is Microsoft, CiviCRM assumes that I changed employers and no longer work for Alphabet. </p>
  
  <p>Unfortunately there isn't a way to my knowledge to stop this from happening or to limit its scope. But it is easy to reactivate any inactive relationships - just becomes an extra step. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T10:10:32.310Z
Answers.Text: That's a pretty big assumption for CiviCRM to make. Increasingly people wear multiple hats in different contexts and work with/for multiple organisations. I might well work for Microsoft, and be attending an event on behalf of a different organisation - maybe a non-profit that I'm working for part-time. Surely there should be a way to allow multiple relationships to persist rather than disabling them on what is pretty thin evidence.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T15:27:35.880Z
Answers.Text: So in your case, how would you know when a relationship is inactive. Or rather, how would you like it to be handled?
Answers.UserDisplayName: themak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-25T14:16:48.577Z
Answers.Text: I don't know when relationships are being inactivated, which is a problem. Getting a notification would be good. How would I like it to be handled? I would like the administrator to be in control of the relationships so that they can choose when they get inactivated.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-19T05:59:25.350Z
Answers.LastActivityDate: 2019-02-19T05:59:25.350Z
Answers.UserDisplayName: themak
Answers.Body: <p>CiviCRM also does "employer relationship magic" if a postal address is shared with another contact. If you share an address with it will create an employer  relationship and disable any existing one.</p>
  
  <p>IMHO this does not make sense but unfortunately it is kind of deeply integrated with the core code. We had to disable/adapt this function for a customer - anyone interested can have a look <a href="https://github.com/systopia/de.boell.civicrm.uimods/blob/master/CRM/Uimods/EmployerRelationship.php" rel="nofollow noreferrer">here</a>. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T10:11:57.957Z
Answers.Text: Again, this is a neat trick if it makes sense in the given context. If it doesn't then it's potentially a massive PITA.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-19T08:28:12.243Z
Answers.LastActivityDate: 2019-02-19T08:28:12.243Z
Answers.UserDisplayName: Fabian
Answers.Body: <p>I do know there is a cron job (Disable expired relationships (Daily)) that inactivates relationships when the end date is in the past. That might be active in your environment, but you state that there are no end dates? Did you not have any in the past either? And is this scheduled job active on your installation?</p>
  
  <p>Another cause might be the employer/employee relationship when you remove the employer from the contact summary?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-14T18:01:05.650Z
Answers.Text: Wot Erik said.
  
  Just had a play in the sandbox. Add current employer. Save, then delete employer (all with inline editting)
  
  https://dmaster.demo.civicrm.org/civicrm/contact/view?reset=1&cid=83
  
  Employer Relationship shows as inactive
Answers.UserDisplayName: Craig Almond
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-15T10:26:28.483Z
Answers.Text: The cron job is active and expired relationships are being disabled. However I'm not setting end dates for relationships, so unless they are being set by some other means that I'm not aware of, this shouldn't be an issue. I'll turn off the job anyway just to see.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-14T09:50:05.813Z
Answers.LastActivityDate: 2019-02-14T09:50:05.813Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I don't make use of the end date in relationships. I only ever explicitly create relationships. And yet I'm aware that there are a significant number of Inactive Relationships in my system. How do these relationships become inactive? It's not a result of manual intervention, so it must be happening programmatically as a result of some other action that is being taken.</p>
  
  <p>I'd love to know what's going on.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-13T20:31:20.620Z
Comments.Text: Are you using civicase? Roles end when the case closes.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-14T09:11:48.000Z
Comments.Text: Thanks, but no. Not using Civicase. I think it might be something to do with merging records, but that's just a guess.
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-14T20:06:59.930Z
Comments.Text: are you using webforms. we just had a case of 'how did that get disabled' - turned out the webform setting had been set to 'disable'
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-15T10:27:41.797Z
Comments.Text: I am using webforms, and I'll check them, but as far as I'm aware they are only ever creating relationships.
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-15T13:36:47.617Z
Comments.Text: Here's a thought: If someone submits a webform and says their current employer is X, then some months later submits a different form and says their current employer is Y, does Civi disable the relationship with X? i.e. does it assume that individuals only ever have one current employer?
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-19T18:55:30.493Z
Comments.Text: Civi only ever has one 'current employer' and that data is stored in civicrm_contact - so yes i expect if a user submits a webform that sets a 'current employer' and they have an existing one, that the existing one would get disabled. OTOH there is nothing to stop a contact having multiple 'is employee of' but only one can be current. There may be a way around the existing one being disabled using webforms but won't try to think it through without knowing that is actually the issue
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-11T15:13:19.730Z
Comments.Text: I posted this question a couple of years ago, and my problem persists. I think that what may be happening is that when I merge records some relationships are getting silently disabled. This is a major issue where that relationship drives a membership, and inclusion in mailing lists, etc., etc. It would be so nice to actually have control of my data!
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-02-15T14:06:09.363Z
Comments.Text: Are you able to turn on advanced logging or add some code that logs during hook_civicrm_post for relationships, or even hacking pear::DB to log updates to civicrm_relationship? That would help determine what exactly is making the updates.
Comments.UserDisplayName: Demerit
Tags: <relationships>
Title: How do relationships become disabled?
ThreadText: # How do relationships become disabled?
  
  (Asked by: username_0 on 2019-02-13)
  
  I don't make use of the end date in relationships. I only ever explicitly create relationships. And yet I'm aware that there are a significant number of Inactive Relationships in my system. How do these relationships become inactive? It's not a result of manual intervention, so it must be happening programmatically as a result of some other action that is being taken.
  
  I'd love to know what's going on.
  
  **Tags:** relationships
  
  > **Comments:**
  > **username_1**: Are you using civicase? Roles end when the case closes.  
  > **username_0**: Thanks, but no. Not using Civicase. I think it might be something to do with merging records, but that's just a guess.  
  > **username_2**: are you using webforms. we just had a case of 'how did that get disabled' - turned out the webform setting had been set to 'disable'  
  > **username_0**: I am using webforms, and I'll check them, but as far as I'm aware they are only ever creating relationships.  
  > **username_0**: Here's a thought: If someone submits a webform and says their current employer is X, then some months later submits a different form and says their current employer is Y, does Civi disable the relationship with X? i.e. does it assume that individuals only ever have one current employer?  
  > **username_2**: Civi only ever has one 'current employer' and that data is stored in civicrm_contact - so yes i expect if a user submits a webform that sets a 'current employer' and they have an existing one, that the existing one would get disabled. OTOH there is nothing to stop a contact having multiple 'is employee of' but only one can be current. There may be a way around the existing one being disabled using webforms but won't try to think it through without knowing that is actually the issue  
  > **username_0**: I posted this question a couple of years ago, and my problem persists. I think that what may be happening is that when I merge records some relationships are getting silently disabled. This is a major issue where that relationship drives a membership, and inclusion in mailing lists, etc., etc. It would be so nice to actually have control of my data!  
  > **username_1**: Are you able to turn on advanced logging or add some code that logs during hook_civicrm_post for relationships, or even hacking pear::DB to log updates to civicrm_relationship? That would help determine what exactly is making the updates.  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2019-02-19. Score: 2
  
  The default action is that the latest employer becomes the active and current employer and the former employer becomes inactive. This occurs because this is what typically people want to happen. As a user registering for an event in 2017, I put my employer as Alphabet, but in 2019, I register for an event, and put my employer is Microsoft, CiviCRM assumes that I changed employers and no longer work for Alphabet.
  
  Unfortunately there isn't a way to my knowledge to stop this from happening or to limit its scope. But it is easy to reactivate any inactive relationships - just becomes an extra step.
  
  > **Comments:**
  > **username_0**: That's a pretty big assumption for CiviCRM to make. Increasingly people wear multiple hats in different contexts and work with/for multiple organisations. I might well work for Microsoft, and be attending an event on behalf of a different organisation - maybe a non-profit that I'm working for part-time. Surely there should be a way to allow multiple relationships to persist rather than disabling them on what is pretty thin evidence.  
  > **username_3**: So in your case, how would you know when a relationship is inactive. Or rather, how would you like it to be handled?  
  > **username_0**: I don't know when relationships are being inactivated, which is a problem. Getting a notification would be good. How would I like it to be handled? I would like the administrator to be in control of the relationships so that they can choose when they get inactivated.  
  
  ---
  
  ### Answer by username_4 on 2019-02-19. Score: 2
  
  CiviCRM also does "employer relationship magic" if a postal address is shared with another contact. If you share an address with it will create an employer relationship and disable any existing one.
  
  IMHO this does not make sense but unfortunately it is kind of deeply integrated with the core code. We had to disable/adapt this function for a customer - anyone interested can have a look [here](https://github.com/systopia/de.boell.civicrm.uimods/blob/master/CRM/Uimods/EmployerRelationship.php).
  
  > **Comments:**
  > **username_0**: Again, this is a neat trick if it makes sense in the given context. If it doesn't then it's potentially a massive PITA.  
  
  ---
  
  ### Answer by username_5 on 2019-02-14. Score: 2
  
  I do know there is a cron job (Disable expired relationships (Daily)) that inactivates relationships when the end date is in the past. That might be active in your environment, but you state that there are no end dates? Did you not have any in the past either? And is this scheduled job active on your installation?
  
  Another cause might be the employer/employee relationship when you remove the employer from the contact summary?
  
  > **Comments:**
  > **username_6**: Wot Erik said.  Just had a play in the sandbox. Add current employer. Save, then delete employer (all with inline editting)  https://dmaster.demo.civicrm.org/civicrm/contact/view?reset=1&cid=83  Employer Relationship shows as inactive  
  > **username_0**: The cron job is active and expired relationships are being disabled. However I'm not setting end dates for relationships, so unless they are being set by some other means that I'm not aware of, this shouldn't be an issue. I'll turn off the job anyway just to see.  
  
  ---
  
  