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) »
  • Changing the Activity API and creating a function to create targets or assignees
Pages: 1 [2]

Author Topic: Changing the Activity API and creating a function to create targets or assignees  (Read 2680 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:20:35 am
I am confused  ???
So in your example the phone 123 is added whatever is in the database already, and 234 is only added if no phone existed before the call? Or only if there is no phone yet for the combination of location_type and phone_type?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:25:06 am
Yeah, I see the hole. I had imagined this scenario

HomePhone = 555

I want to add another home phone - I send in the add details with 'add' set

OR

I want home phone to be 789 so I don't set 'add' and 789 will be THE home phone entry - if one (or more!) exist already they would be replaced by 789.

The hole I'm just noticing is the 'or more!'
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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:28:55 am
Exactly, that hole makes it difficult to cater for all situations at one level. In the ideal world you need the primary key of the entity to be able to decide if it needs to changed or added, and we do not know that for the phones in location or the target contacts in the Activity. I think there is two scenarios we can provide at the generic level:
  • replace a single of there is only one (and return an error/warning if there are more)
  • replace the whole set (so all the phones or target contacts with what is in the parms)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:30:45 am
So, I make it 3 options:

action = 'add' ||  'replace_single' ||  'replace_all'
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: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:33:11 am
I think the api should be as dumb as possible (but not dumber ;)

If you have a phone param (an array of array scares me by the way). it considers it contains the full list of phones. If you had already phones for the contacts that aren't in the array, tough luck, it's deleted.

We might want to create a new civicrm_phone api, where you can add a single phone, but the normal way is to _get the location, add in the array your phone, and _update.

X+

P.S. What do it do now ? I think it does it that way already, doesn't it ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:41:38 am
I think it does, but it is on the agenda for today so I should now later today.....but I need the approach to solve the Acitivity one as well.
Can we agree on this approach:
  • if we are in update mode we assume the params contain the full list, and replace whatever is there
  • we add a function in the Location API :civicrm_phone_add which adds a single phone to the existing list
We use that pattern consistently in the API's?

By the way, I did not have a true warm beer yet. The bottled stuff we had so far was either Belgium, Italian, Indian or Polish. But we did try cider....and I do need one warm beer tonight I think, if only because Eileen said I could have one :-) We did have a good greasy breakfast this morning!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 02:58:13 am
Pleased to hear you are partaking in the 'cuisine' of England.

I'm afraid I'm having a cider right now which is starting to adle my thoughts on this....

I think the location api is particularly tricky because it does allow several different locations to be dealt with at once. I think you're on the right track. At the end of the day knowing what the 'standard' behaviour is is the number 1 priority
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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 03:06:34 am
Having lived in the UK I am fairly used to the English 'cuisine'....but I can assure you my wife usually has a comment or two if English and cuisine are used in the same sentence :-)

I will first try to apply the rule to the Activity API and see what that looks like then, and add the rule to the conventions Wiki page.
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 03:21:30 am
I have a feeling Xavier might have some thoughts on the topic too....
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

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 03:45:29 am
I am sure he does....we have exchanged some meaningful glances over food in the last couple of days, with Marmite as the central point of attention. Enjoy your cider!
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Changing the Activity API and creating a function to create targets or assignees
October 05, 2010, 04:08:13 am
And erik wins an extra point to put food and marmite in the same sentence;)
I always thought it was a waste product of the beer industry.

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

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Changing the Activity API and creating a function to create targets or assignees

This forum was archived on 2017-11-26.