Timeline for HOWTO remove inherited membership when corresponding relationship is disabled or deleted?
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 7, 2017 at 17:26 | comment | added | Aidan♦ | If you want to update the existing relationship by API, you need to specify the id. You can do a Get first specifying the contact_id's and the relationship_type and then an update. If the csv import extension is requiring contact_id's then you can't use it to update. You could fairly easily create a script to read your csv, then do the get/update for each line. If you want to create a separate question about using the csv & api I'll add an answer there but no space in these comments! | |
Oct 4, 2017 at 18:56 | comment | added | Karl Rudnick | One last comment here on the utility of API csv Import extension to do the work here. I figured I could create a 2-column CSV file with columns relationship_id, is_active, once I have a list of relevant relationship_id's, which seems you need either an SQL query OR use of api('Relationship','get',...). THIS DOESN'T WORK - the API csv Import extension requires contact_id_a, contact_id_b, relationship_type_id and it won't import with that added because of duplicate relationships - it tries to create an entirely new relationship record rather than just update is_active. error="Duplicate..." | |
Oct 4, 2017 at 4:40 | vote | accept | Karl Rudnick | ||
Oct 4, 2017 at 4:39 | comment | added | Karl Rudnick | OK. I figured I need 2 steps. (i) $result = civicrm_api3('Relationship', 'get', array( 'sequential' => 1, 'return' => array("id"), 'contact_id_a' => 389, 'contact_id_b' => 384, ; ... Returns id=319. Then execute $result = civicrm_api3('Relationship', 'create', array( 'sequential' => 1, 'id' => 319, 'is_active' => 0, )); This both disables the relationship between 389 and 384, while at the same time making the Membership inactive. Again, many thanks @Aidan. | |
Oct 4, 2017 at 4:19 | comment | added | Karl Rudnick | I'll also add that I tried using the "API csv Import" extension with 4 columns: contact_id_a, contact_id_b, relationship_type_id, is_active set the same way as in the API Eplorer snippet. It will not import any rows where the relationship already exists with the same error: "Duplicate Relationship." I can do this in SQL. What am I missing in the API? | |
Oct 4, 2017 at 4:12 | comment | added | Karl Rudnick | I cannot get this to work. In API Explorer, I constructed this sample snippet. $result = civicrm_api3('Relationship', 'create', array( 'sequential' => 1, 'contact_id_a' => 389, 'contact_id_b' => 384, 'relationship_type_id' => 17, 'is_active' => 0, )); I get an error message: "Duplicate Relationship". The relationship DOES exist with is_active=1. We just want to change that field to 0. I tried "replace" instead of "create" and get the error message: "Mandatory key(s) missing from params array: values" Note that UPDATE is deprecated. It says to use create. We just want to UPDATE. | |
Oct 3, 2017 at 11:58 | comment | added | Karl Rudnick | One more question. We have been successfully using the API csv Import extension. We were hoping to invoke the API via a list with something like a 3 column csv file, each row containing contact_id_a, contact_id_b, relationship_type_I'd. We often have 20-300 rows of enabling and/or disabling these relationships annually for our organizations (bicycle clubs). Do you know if that capability exists? If not, might it be easy to add to that? | |
Oct 3, 2017 at 11:50 | vote | accept | Karl Rudnick | ||
Oct 4, 2017 at 4:10 | |||||
Oct 3, 2017 at 11:46 | comment | added | Karl Rudnick | Thanks for both the API and cv tips. I was searching around the API documentation and had difficulty figuring out how to do exactly what I wanted. I'll head down that road. Understanding the database details was still useful for us as we haven't done much under the hood to date. Many thanks, Aidan! | |
Oct 3, 2017 at 8:17 | history | edited | Aidan♦ | CC BY-SA 3.0 |
added 1 character in body
|
Oct 3, 2017 at 8:07 | history | answered | Aidan♦ | CC BY-SA 3.0 |