CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • relationship_replace
Pages: [1]

Author Topic: relationship_replace  (Read 752 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
relationship_replace
December 03, 2012, 09:14:09 pm
I have a need for a sort of relationship replace function. I'm wondering if there is a generic use-case (I have seen it more than once). The call would look like the generic 'replace' except that instead of deleting the replaced relationships it would end them / set them to be inactive. This is applicable, for example, when I change branch president or chair person.

so the requirement would be to end all existing active relationships of type x with contact_b = y and then create a new one with contact_a = z
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: relationship_replace
December 03, 2012, 10:39:32 pm
So replace for group would set the old one(s) as inactive to take another example?

How would look the call? How do you define what needs to be replaced? Resumably not all the exisisting groups/relationship?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: relationship_replace
December 04, 2012, 12:25:47 am
The existing replace function looks like this -it basically deletes all the emails for contact_id => 1 & then creates new ones for that contact

http://svn.civicrm.org/civicrm/trunk/api/v3/examples/EmailReplace.php
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: relationship_replace
December 04, 2012, 05:21:54 am
I don't have strong feelings either way, think it makes sense to disable for groupcontact or relationship.

However, I'm wondering that if you have api.relationship.replace that disable only from one type (still not super sure on how could look the param) then users might expect to have
api.email.replace behaving the same, and be able to replace only the fax, or only the home phones?

In other words, deleting more than thought?

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: relationship_replace
December 04, 2012, 12:04:20 pm
Yes, I'm not sure - I can't think of an alternative useful verb though. The wiki does have red text around replace function :-)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: relationship_replace
December 04, 2012, 01:56:59 pm
That's a very well known fact than every dev reads the fm before doing anything...
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: relationship_replace
December 04, 2012, 02:08:59 pm
True - I'd quite like to add something to the metadata that provides info about the function not just the fields
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • relationship_replace

This forum was archived on 2017-11-26.