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) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Community Sponsored Improvements (Moderator: Donald Lobo) »
  • New CiviCase API
Pages: [1] 2

Author Topic: New CiviCase API  (Read 6071 times)

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
New CiviCase API
May 07, 2010, 10:23:55 am
Hi folks, here is a new API for creating cases that we developed for woolman.org.
It is pretty bare-bones, and doesn't do a lot of validation. Feedback and patches are more than welcome.
(to use it, place it in civicrm/api/V2, and strip off the .txt extention).
Try asking your question on the new CiviCRM help site.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: New CiviCase API
May 07, 2010, 06:55:01 pm

hey coleman:

would be great if you can also write a unit test for it (tests/phpunit/api/v2/) so we can commit both the api and test to svn

check: http://wiki.civicrm.org/confluence/display/CRM/Testing for more details or ping us on IRC to get started

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
May 07, 2010, 08:17:16 pm
Thanks, we'll check it out.
Try asking your question on the new CiviCRM help site.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New CiviCase API
May 08, 2010, 02:17:41 am
Great,

Could you detail what does do the civicrm_case_add_activities vs. civicrm_case_add ?
Is the former creating the activities based on the timeline on the top of creating the case itself ?

Also, could you add a civicrm_case_delete and civicrm_case_get ? (will probably need it for the tests anyway)

Also, while that's fresh document the new api ? what is expected into the params is especially useful for folks trying to use it.
http://wiki.civicrm.org/confluence/display/CRMUPCOMING/CiviCRM+Public+APIs

Did you read the new chapter about the API in the book ?
http://en.flossmanuals.net/CiviCRM/DevelopAPI
Feedback more than welcome, we still have a few days before it goes to print, please tell me if something is missing or wasn't clear.

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

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
May 08, 2010, 09:27:20 am
xavier: you're correct. civicrm_case_add is needed for generating a new case ID.  That id is then used as an argument in civicrm_case_add_activities to define the client and manager ids, and auto-generate the timeline based on the xml file. Opening a new case requires both functions.
Here's an example use:
Code: [Select]
  civicrm_initialize( );
  require_once 'CRM/Core/Config.php';
  $config =& CRM_Core_Config::singleton( );

  require_once 'api/v2/Case.php';

             // create new case
             $params = array(  'case_type_id'  => '1', //not sure what these funny symbols are for, but they seem to be needed
                              'start_date'    => 20101225,  // this is what next christmas looks like as a date string
                              'status_id'      => 1, // ongoing
                      );
         
            $new_case = civicrm_case_add( $params ); // returns case id as $new_case['result']

            // configure new case
             $params = array(  'case_id'          => $new_case['result'],
                              'case_type'        => 'Christmas Case',
                              'contact_id'      => 333, // the client
                              'creator_id'      => 444, // the case manager
                              'activity_subject'=> 'Jingle Bells',
                              'location'        => 'The North Pole',
                              'start_date'      => 20101225,
                              'medium_id'        => '1', //"In Person"
                              'duration'        => '',
                              'details'          => '',
                      );

            $result = civicrm_case_add_activities($params);
         
            // FYI, you can add additional contacts to case using relationship api
           
  require_once 'api/v2/Relationship.php';
             
              $params = array(
                    'contact_id_a'         => 333, // case client
                    'contact_id_b'         => 222, // frosty the snowman
                    'relationship_type_id' => 13,
                    'is_active'            => 1,
                    'case_id'               => $new_case['result'],
                    );
            $result = & civicrm_relationship_create( $params );

I would be happy to add this documentation to the appropriate place, but I'm not sure where that is. I know API documentation is in flux, so if someone could tell me where it should go, I will put it there.
Try asking your question on the new CiviCRM help site.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
May 08, 2010, 09:36:43 am
Now that I think about it, it may be an improvement to roll the two case_add functions into one and take all the arguments at once.  Seems like you'd never want to use one without the other anyway.  Thoughts?
Try asking your question on the new CiviCRM help site.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: New CiviCase API
May 09, 2010, 03:12:43 pm
>
> $params = array(  'case_type_id'  => '1', //not sure what these funny symbols are for, but they seem to be needed
>

Cool stuff.

To answer the comment, in the original implementation there was some discussion about having case type be multi-valued. The funny symbols are civi's way of storing multiple values in a single string (although sometimes it uses PHP serialize the same as other projects like Drupal, so this method is probably historical.)

If you use the CRM_Core_DAO::VALUE_SEPARATOR constant instead of the symbol directly the code will be more future-proof and readable.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New CiviCase API
May 10, 2010, 01:16:26 am
Quote from: colemanw on May 08, 2010, 09:36:43 am
Now that I think about it, it may be an improvement to roll the two case_add functions into one and take all the arguments at once.  Seems like you'd never want to use one without the other anyway.  Thoughts?

Mean adding a boolean params[create_activities] (or whatever the name) in case_add ? Would make sense to me
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
July 16, 2010, 10:57:33 am
Latest issues for this API now at http://issues.civicrm.org/jira/browse/CRM-6298
Try asking your question on the new CiviCRM help site.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
August 01, 2010, 07:47:11 pm
At last: I have finished my rewrite of the Case API. It contains dozens of bug fixes, several new features, lots of code cleanup, and documentation for every function. I have made every effort to conform to the CiviCRM API standards, which meant renaming and merging several functions (sorry to the few people who were already using this api, but trust me, it's for the best).
I hope you all love it as much as I do. Please send me your feedback.
« Last Edit: August 02, 2010, 09:53:44 am by colemanw »
Try asking your question on the new CiviCRM help site.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: New CiviCase API
August 02, 2010, 09:40:40 am

hey coleman:

can you please file a new issue and attach this file there

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
August 02, 2010, 09:53:58 am
Here it is:
http://issues.civicrm.org/jira/browse/CRM-6573
Try asking your question on the new CiviCRM help site.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: New CiviCase API
August 05, 2010, 07:21:53 pm
Hi,

Did you write a unit test as well ?

Could you attach it to the issue ?

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

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: New CiviCase API
August 05, 2010, 08:38:34 pm
I'm not going to have time to do that in the near future, but I noticed in the other thread that Crossroads Foundation said they might be able to do it.
Try asking your question on the new CiviCRM help site.

Andrew Perry

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 1
  • Building empowering tools that comply with rules
    • Community Builders Australia
  • CiviCRM version: 3.x, 4.x
  • CMS version: Joomla 1.0.x, 1.5.x -> Drupal 6.x, 7.x, WordPress
  • MySQL version: 5.1, 5.5, 5.6
  • PHP version: 5.2, 5.3, 5.4
Re: New CiviCase API
December 21, 2010, 04:16:32 pm
colemanw: Just wanted to say how much your work on the CiviCase API is appreciated!

We have been using CiviCRM for about 5 years but built a case management system alongside it at the beginning of that time and are now finally moving everything across into CiviCase.

Last night I imported over 1,000 cases in a few minutes!  Awesome stuff!!

Do you or your org have a PayPal account we can make a small contribution to as a thank-you for contributing this?

Thanks again!

Andrew
Community Builders Australia Pty Ltd
www.communitybuilders.com.au

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions »
  • Community Sponsored Improvements (Moderator: Donald Lobo) »
  • New CiviCase API

This forum was archived on 2017-11-26.