Answers.Body: <p>This is not currently possible so I have opened issue <a href="https://www.drupal.org/node/2853352" rel="nofollow noreferrer">here</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-18T21:12:49.393Z
Answers.Text: Sorry. Thought I was in the comment area.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-18T21:18:37.343Z
Answers.Text: nw. i just edited this so it would look more like an answer ;-)
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-16T23:04:25.843Z
Answers.LastActivityDate: 2017-02-18T21:18:09.070Z
Answers.LastEditDate: 2017-02-18T21:18:09.070Z
Answers.UserDisplayName: pmoz
Answers.Body: <p>If I understand the issue correctly, it sounds like there's a bug where webform attempts to disable a relationship but instead creates a <em>new</em> disabled relationship. This may be due to recent upstream changes in the Civi api - iirc the v3 relationship api is a little odd.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-22T17:22:47.657Z
Answers.LastActivityDate: 2018-01-22T17:22:47.657Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>I just did a simple test and it appears to be working ok. This is what I did (using the latest version of CiviCRM and Webform-CiviCRM):</p>
  
  <ul>
  <li>Create a simple webform with 2 contacts</li>
  <li>Contact 2 - relationship to contact 1 (sibling) - relationship is active: "User Select"</li>
  <li>Contact 2 "existing contact" field - autocomplete.</li>
  <li>Submit the form with relationship is active: yes</li>
  <li>Observe the active relationship in CiviCRM</li>
  <li>Submit the form with the same 2 contacts, relationship is active: no</li>
  <li>Observe the same relationship in CiviCRM is no longer active. No duplicate relationship created.</li>
  </ul>
  
  <p>EDIT by pmoz:
  I wanted to make sure that the next time I need this I have clear documentation.<p>
  Create the webform with 3 contacts (Case Client, Old Case Coordinator and New Case Coordinator) and 1 ongoing case.<p>
  On the Old Case Coordinator Civi-webform settings enable relationships and select Case Coordinator as the relationship to participant and user select for is active.<p>
  You do not need to enable relationships on the New Case Coordinator Civi-webform settings. I only enable the existing contact field.<p>
  On the Civi-webform Case page, select Update Open cases, and under roles set the case client as contact 1 and the case coordinator as New Case Coordinator (contact 3).<p>
  That's it for the Civi -webform settings.<p>
  In the webform components, navigate to the Old Case Coordinator edit page and add the case role to prefill the field on the webform.<p>
  <a href="https://i.sstatic.net/EHeJe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EHeJe.png" alt="enter image description here"></a><p>
  To access the form use node/111?cid1=<em>caseclientid</em>&amp;case1=<em>caseid</em>. The form should be prefilled with the case client, old case coordinator and the case type if you have multiple case types.<p>
  This is the only combination that I could get to correctly add the relationship within the case.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-17T22:06:26.297Z
Answers.Text: The OP related specifically to Case but this answer doesn't mention it in the steps above. So it may be a good answer, just unclear at this point. Will have a look next week
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-07T05:04:21.373Z
Answers.Text: Tested the above with a case via creating a webform with 3 contacts (all existing) and a case. Case client set to contact 1 and a 'test case role' set to be user select. Contact 2 autocompletes from relationship to Contact 1 and has 'Relationship is Active: User Select'. Submit form with Relationship is Active: NO, a contact for Contact 3 and 'Test Case Role = Contact 3". This disabled the 'Test Case Role' relationship between 1 and 2 and created a new 'Test Case Role' relationship between 1 and 3
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-05-21T21:15:04.847Z
Answers.Text: Added details to the answer.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-02-17T18:25:03.277Z
Answers.LastActivityDate: 2020-06-01T17:33:46.997Z
Answers.LastEditDate: 2020-06-01T17:33:46.997Z
Answers.UserDisplayName: Coleman
Body: <p>Scenario:</p>
  
  <p>A case has a Purchasing Partner role. Sometimes that needs to be changed and we want to do so via a webform (from a View with links containing whatever cid1 etc it needs).</p>
  
  <p>My testing shows that if I try with just the cid1 (who is case client) and cid2 (who is existing PP) in the url and add a third cid for the new partner, when we submit the form we hope it will </p>
  
  <ul>
  <li>terminate the Relationship between cid1 and cid2 (which seems to be how I can do this on a contacts record directly in civi itself and the only way i can approach this on the webform since there is no option to eg specify 'remove existing case role') and</li>
  <li>create a Case Role for cid 3</li>
  </ul>
  
  <p>the outcome is that</p>
  
  <ul>
  <li>the original relationship between cid1 and cid2 remains untouched, and a new disabled (due to End Date) relationship is created between cid1 and 2</li>
  <li>a new case role and relationship is created for cid 3</li>
  </ul>
  
  <p>Should we be able to do this as webform code stands? Does adding the caseid=x help (i did test that but saw no difference)</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-28T15:15:32.060Z
Comments.Text: Pete, I have tried every possible combination and cannot get this to work either. Unfortunately for now I have folks going into the back end to change case roles but that is not the preferred implementation in our case. Wish I had an answer for you.
Comments.UserDisplayName: pmoz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-28T15:19:22.300Z
Comments.Text: I wonder if it could be tied to the A-B relationship. When I create add a case role in Civi, it calls the relationship **case manager**. When I use webform to assign a case role by using the case tab on the webform it creates the relationship **case manager is** not **case manager**.
Comments.UserDisplayName: pmoz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-15T11:04:16.163Z
Comments.Text: This continues to be a big issue for me on multiple installs. Has anyone found a work-around?
Comments.UserDisplayName: pmoz
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-15T19:20:00.853Z
Comments.Text: You might need to get an estimate from Coleman, maybe via drupal.org
Comments.UserDisplayName: petednz - fuzion
Tags: <webform-civicrm><civicase><relationships><roles>
Title: Can webform be used to terminate one Case Role and create a replacement?
ThreadText: # Can webform be used to terminate one Case Role and create a replacement?
  
  (Asked by: username_0 on 2016-10-06)
  
  Scenario:
  
  A case has a Purchasing Partner role. Sometimes that needs to be changed and we want to do so via a webform (from a View with links containing whatever cid1 etc it needs).
  
  My testing shows that if I try with just the cid1 (who is case client) and cid2 (who is existing PP) in the url and add a third cid for the new partner, when we submit the form we hope it will
  
  * terminate the Relationship between cid1 and cid2 (which seems to be how I can do this on a contacts record directly in civi itself and the only way i can approach this on the webform since there is no option to eg specify 'remove existing case role') and
  * create a Case Role for cid 3
  
  the outcome is that
  
  * the original relationship between cid1 and cid2 remains untouched, and a new disabled (due to End Date) relationship is created between cid1 and 2
  * a new case role and relationship is created for cid 3
  
  Should we be able to do this as webform code stands? Does adding the caseid=x help (i did test that but saw no difference)
  
  **Tags:** webform-civicrm, civicase, relationships, roles
  
  > **Comments:**
  > **username_1**: Pete, I have tried every possible combination and cannot get this to work either. Unfortunately for now I have folks going into the back end to change case roles but that is not the preferred implementation in our case. Wish I had an answer for you.  
  > **username_1**: I wonder if it could be tied to the A-B relationship. When I create add a case role in Civi, it calls the relationship **case manager**. When I use webform to assign a case role by using the case tab on the webform it creates the relationship **case manager is** not **case manager**.  
  > **username_1**: This continues to be a big issue for me on multiple installs. Has anyone found a work-around?  
  > **username_0**: You might need to get an estimate from username_2, maybe via drupal.org  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_2 on 2018-02-17. Score: 1 | Accepted answer
  
  I just did a simple test and it appears to be working ok. This is what I did (using the latest version of CiviCRM and Webform-CiviCRM):
  
  * Create a simple webform with 2 contacts
  * Contact 2 - relationship to contact 1 (sibling) - relationship is active: "User Select"
  * Contact 2 "existing contact" field - autocomplete.
  * Submit the form with relationship is active: yes
  * Observe the active relationship in CiviCRM
  * Submit the form with the same 2 contacts, relationship is active: no
  * Observe the same relationship in CiviCRM is no longer active. No duplicate relationship created.
  
  EDIT by username_1:
  I wanted to make sure that the next time I need this I have clear documentation.
  
  Create the webform with 3 contacts (Case Client, Old Case Coordinator and New Case Coordinator) and 1 ongoing case.
  
  On the Old Case Coordinator Civi-webform settings enable relationships and select Case Coordinator as the relationship to participant and user select for is active.
  
  You do not need to enable relationships on the New Case Coordinator Civi-webform settings. I only enable the existing contact field.
  
  On the Civi-webform Case page, select Update Open cases, and under roles set the case client as contact 1 and the case coordinator as New Case Coordinator (contact 3).
  
  That's it for the Civi -webform settings.
  
  In the webform components, navigate to the Old Case Coordinator edit page and add the case role to prefill the field on the webform.
  
  [![enter image description here](https://i.sstatic.net/EHeJe.png)](https://i.sstatic.net/EHeJe.png)
  
  To access the form use node/111?cid1=*caseclientid*&case1=*caseid*. The form should be prefilled with the case client, old case coordinator and the case type if you have multiple case types.
  
  This is the only combination that I could get to correctly add the relationship within the case.
  
  > **Comments:**
  > **username_0**: The OP related specifically to Case but this answer doesn't mention it in the steps above. So it may be a good answer, just unclear at this point. Will have a look next week  
  > **username_0**: Tested the above with a case via creating a webform with 3 contacts (all existing) and a case. Case client set to contact 1 and a 'test case role' set to be user select. Contact 2 autocompletes from relationship to Contact 1 and has 'Relationship is Active: User Select'. Submit form with Relationship is Active: NO, a contact for Contact 3 and 'Test Case Role = Contact 3". This disabled the 'Test Case Role' relationship between 1 and 2 and created a new 'Test Case Role' relationship between 1 and 3  
  > **username_1**: Added details to the answer.  
  
  ---
  
  ### Answer by username_1 on 2017-02-16. Score: 2
  
  This is not currently possible so I have opened issue [here](https://www.drupal.org/node/2853352).
  
  > **Comments:**
  > **username_1**: Sorry. Thought I was in the comment area.  
  > **username_0**: nw. i just edited this so it would look more like an answer ;-)  
  
  ---
  
  ### Answer by username_2 on 2018-01-22. Score: 0
  
  If I understand the issue correctly, it sounds like there's a bug where webform attempts to disable a relationship but instead creates a *new* disabled relationship. This may be due to recent upstream changes in the Civi api - iirc the v3 relationship api is a little odd.
  
  
  ---
  
  