Answers.Body: <p>I'll assume none of them are case relationships which makes it simpler.</p>
  <p>Put the contacts in a group (a regular group not smart). Then you could do something like</p>
  <pre><code>UPDATE civicrm_relationship r
  INNER JOIN civicrm_group_contact c ON
   (c.contact_id = r.contact_id_a
    AND r.relationship_type_id = the_relationship_type_id
    AND c.group_id = the_group_id_of_the_group_you_just_made
   ) 
  SET r.end_date = CURDATE()-1;
  </code></pre>
  <p>Obviously replace <code>the_relationship_type_id</code> and <code>the_group_id_of_the_group_you_just_made</code> with the appropriate id numbers.</p>
  <p>Depending on how your relationship type is defined you may need to switch contact_id_b instead of contact_id_a in the query. You can also set is_active=0 if you want.</p>
  <p>Since you just created the group just now you don't have to think about status in that query. You can now get rid of the group.</p>
  <p>Note if you have extensions that do things when relationships are changed this will bypass them. This also wouldn't work with employer/employee since there's extra stuff that happens when those change.</p>
  <p>There is probably a way to do this with API but it might take some trial and error to get the joins for update.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-05T12:21:32.433Z
Answers.Text: Thanks Dave, this was a speed way of updating the relationship though a bit different from what I was thinking of. Did the job!
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-04T21:30:47.420Z
Answers.LastActivityDate: 2021-08-04T21:30:47.420Z
Answers.UserDisplayName: Demerit
Body: <p>I've a bunch of contacts with one no more needed relationship that I want to bulk delete.</p>
  <p>It's a batch of 500 contacts that have 2 relationships and one is outdated, something like <code>volunteer for</code> and <code>helps for</code>. I need to suppress one of the two as it is no more needed. This group is easy to identify but I can't find any quick action to do this. I don't want to hard delete the target relationship in database because it is still needed for some other contacts. What I need is to bulk remove this particular relationship from a certain batch of contacts.</p>
  <p>Is there a way to do this in the UI? Or with the API?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-03T15:45:49.207Z
Comments.Text: Possibly - could you please edit your question to give more details?  Are you deleting all relationships of a certain type?  All relationships on certain contacts? Etc.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-04T07:51:21.960Z
Comments.Text: thanks Jon. Is it more understandable now?
Comments.UserDisplayName: Guillaume Sorel
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-04T21:50:19.770Z
Comments.Text: Hi Guillame,
  
  So you have 500 contacts. each with a volunteer for and a help for relationship. with another contact.
  
  You no longer need "helps for" in this context, and want to remove the relationship from those 500 contacts. 
  
  As far as I can see there isn't a way in the ui
  Search result actions allow you to add relationships not remove them.
  And relationships aren't configurable within profiles for a batch update.
  
  I don't use the API much myself, so don't know after that.
Comments.UserDisplayName: Craig Almond
Tags: <relationships>
Title: Bulk update of relationships
ThreadText: # Bulk update of relationships
  
  (Asked by: username_0 on 2021-08-03)
  
  I've a bunch of contacts with one no more needed relationship that I want to bulk delete.
  
  It's a batch of 500 contacts that have 2 relationships and one is outdated, something like `volunteer for` and `helps for`. I need to suppress one of the two as it is no more needed. This group is easy to identify but I can't find any quick action to do this. I don't want to hard delete the target relationship in database because it is still needed for some other contacts. What I need is to bulk remove this particular relationship from a certain batch of contacts.
  
  Is there a way to do this in the UI? Or with the API?
  
  **Tags:** relationships
  
  > **Comments:**
  > **username_1**: Possibly - could you please edit your question to give more details?  Are you deleting all relationships of a certain type?  All relationships on certain contacts? Etc.  
  > **username_0**: thanks Jon. Is it more understandable now?  
  > **username_2**: Hi Guillame,  So you have 500 contacts. each with a volunteer for and a help for relationship. with another contact.  You no longer need "helps for" in this context, and want to remove the relationship from those 500 contacts.   As far as I can see there isn't a way in the ui Search result actions allow you to add relationships not remove them. And relationships aren't configurable within profiles for a batch update.  I don't use the API much myself, so don't know after that.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2021-08-04. Score: 2 | Accepted answer
  
  I'll assume none of them are case relationships which makes it simpler.
  Put the contacts in a group (a regular group not smart). Then you could do something like
  UPDATE civicrm_relationship r
  INNER JOIN civicrm_group_contact c ON
   (c.contact_id = r.contact_id_a
    AND r.relationship_type_id = the_relationship_type_id
    AND c.group_id = the_group_id_of_the_group_you_just_made
   ) 
  SET r.end_date = CURDATE()-1;
  
  Obviously replace the_relationship_type_id and the_group_id_of_the_group_you_just_made with the appropriate id numbers.
  Depending on how your relationship type is defined you may need to switch contact_id_b instead of contact_id_a in the query. You can also set is_active=0 if you want.
  Since you just created the group just now you don't have to think about status in that query. You can now get rid of the group.
  Note if you have extensions that do things when relationships are changed this will bypass them. This also wouldn't work with employer/employee since there's extra stuff that happens when those change.
  There is probably a way to do this with API but it might take some trial and error to get the joins for update.
  
  > **Comments:**
  > **username_0**: Thanks Dave, this was a speed way of updating the relationship though a bit different from what I was thinking of. Did the job!  
  
  ---
  
  