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) »
  • Hook on case change client and case merge cases
Pages: [1]

Author Topic: Hook on case change client and case merge cases  (Read 788 times)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Hook on case change client and case merge cases
March 31, 2014, 05:35:34 am
Hey all,

Is there a hook available for when a case is reassigned to another client? And in addition is there a hook when a case is merged with another case?

I need such hooks because I have developed a document solutions for civicrm and I want to store (link) documents to a case but as soon as a case is reassigned the documents disappear (because the old case is deleted). The same is true on a merge case.

Thanks,
Jaap
Developer at Edeveloper / CiviCoop

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Hook on case change client and case merge cases
March 31, 2014, 06:57:52 am
If hook_civicrm_post doesn't do it, maybe we need to add hooks for this.
Try asking your question on the new CiviCRM help site.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Hook on case change client and case merge cases
March 31, 2014, 07:07:26 am
The hook post is called but it doesn't give a clue wether this was a save on a new case, edit existing one, or a merge or a reassign...

I am happy to implement such a hook. Shall I register an issue for this and start working on it?
Developer at Edeveloper / CiviCoop

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Hook on case change client and case merge cases
March 31, 2014, 07:08:35 am
Sounds good to me.
Try asking your question on the new CiviCRM help site.

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Hook on case change client and case merge cases
March 31, 2014, 07:48:06 am
I have added an issue to the issue trakcer: https://issues.civicrm.org/jira/browse/CRM-14409
And created a pull request (https://github.com/civicrm/civicrm-core/pull/2782)

This PR contains two hooks
a civicrm_pre_case_merge and a civicrm_post_case_merge both hooks have the same parameters as the mergecases function in the CRM_Case_BAO_Case class.
Developer at Edeveloper / CiviCoop

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: Hook on case change client and case merge cases
March 31, 2014, 11:39:52 pm
Do you want to do this as separate hooks? I think it would make more sense to me to have it in the civicrm_post hook, with object Case and $op 'merge' or 'reassign'?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Hook on case change client and case merge cases
April 01, 2014, 12:31:22 am
That would definitely make sense if the hook pre and the hook post had an ability to use two objects (two cases). But they haven't so I had to use this solution. Also the way a case is reassigned could be refactored so that on a reassign it would not do a merge of the original case and a new one (and then deleting the old one).
Developer at Edeveloper / CiviCoop

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: Hook on case change client and case merge cases
April 01, 2014, 02:22:15 am
Once more proof that the way CiviCase works should be overhauled a bit....but I guess we will have to find some funding first  ;D
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: Hook on case change client and case merge cases
April 01, 2014, 02:47:22 pm
I just added a new hook to the reference - http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference - it seemed confusion so I added (from 4.5) in the title so it would show on the page of contents - not sure if there is a better way
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

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Hook on case change client and case merge cases
April 02, 2014, 02:13:56 am
Hey Eileen,

I don't see the documentation of the hook....
I think you have replied on the wrong topic..
Developer at Edeveloper / CiviCoop

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Hook on case change client and case merge cases
April 02, 2014, 02:25:46 am
sorry - I meant - I just added another hook to that reference - I am assuming you are about to add these new ones to it & might hit the question I did - how to make it clear in the main hook reference page that this hook is only available from version x.

- I put (from 4.5) in the title of the new hook - so it would show up in the table of contents. Not sure if that is a good approach
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

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Hook on case change client and case merge cases
April 02, 2014, 03:40:36 am
Yes, I was not sure about the documentation yet. I thought I would definitly update the docs as soon as 4.4.5 comes out. But this would save me some work by then.
Developer at Edeveloper / CiviCoop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Hook on case change client and case merge cases

This forum was archived on 2017-11-26.