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) »
  • case and activity apis
Pages: [1]

Author Topic: case and activity apis  (Read 922 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
case and activity apis
December 13, 2010, 01:48:04 pm
for the eminent API team...

the case_create api states that status_id is optional, but if params are passed without it, it errors, stating it is required. personally I think it should be optional, with default status = ongoing (as docs suggest)

also, it seems very difficult to retrieve case activities right now. in fact, it may be impossible, as i don't think we ever capture the link between the case and activities. for example, if i want to create a case and then modify the associated open case activity, it doesn't look like i can do that via the api.

support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: case and activity apis
December 13, 2010, 03:18:37 pm
Hi,

Could you add a test if the status id is not present in the params and set it to ongoing if not the case?

(not sure if it should be down to the BAO level, but in the API seems to be good enough)

Not sure about fetching the activities, is the case id stored in the source or elsewhere?

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

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: case and activity apis
December 14, 2010, 06:01:45 am
i was using the case_create api and originally did not include the status_id in the params (as the comments indicate it is optional and will default to ongoing if absent) -- but on running the code, it yielded an error stating it's a required field. so i'm just suggesting we either fix so that it truly is optional, or alter the documentation/comments to state it's required. (not sure if that's what you were looking for...)

re: case activities --
i think we just need an api that accesses CRM_Case_BAO_Case::getCaseActivity()
...which is a pretty robust function

one other suggestion/request (though not technically API related) --
I was working on a project where I am opening a case and populating custom fields attached to the open case activity type through a frontend form (anonymous user). i piggybacked on a profile create form, just adding the necessary fields and handling the case creation/activity update via buildForm and postProcess hooks. all good -- except i wanted to email the activity after submission using CRM_Case_BAO_Case::sendActivityCopy() -- and couldn't because that function retrieves the userID in order to set the FROM value for the email -- which doesn't exist if the user is anonymous. it was easy enough to fix for my purposes (i just hardcoded my FROM email if no userID exists), but it would be nice to really fix it so that it retrieves the system default FROM email if no userID is set.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: case and activity apis
December 14, 2010, 10:57:12 am
Quote from: lcdweb on December 14, 2010, 06:01:45 am
one other suggestion/request (though not technically API related) --
I was working on a project where I am opening a case and populating custom fields attached to the open case activity type through a frontend form (anonymous user). i piggybacked on a profile create form, just adding the necessary fields and handling the case creation/activity update via buildForm and postProcess hooks. all good -- except i wanted to email the activity after submission using CRM_Case_BAO_Case::sendActivityCopy() -- and couldn't because that function retrieves the userID in order to set the FROM value for the email -- which doesn't exist if the user is anonymous. it was easy enough to fix for my purposes (i just hardcoded my FROM email if no userID exists), but it would be nice to really fix it so that it retrieves the system default FROM email if no userID is set.

Makes sense (even so not really api related indeed). Is the code you mention shared somewhere?

(I'll dig myself in the case/new frontend, will note down what issues I bump into and see what's missing in the common part)
-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: case and activity apis
December 15, 2010, 01:39:06 am
Brian

Quote
but it would be nice to really fix it so that it retrieves the system default FROM email if no userID is set.

The UpdateMembership.php in the bin dir recently got updated to do this so if you do some svn sniffing on that file you should home in on the code pretty quickly
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) »
  • case and activity apis

This forum was archived on 2017-11-26.