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) »
  • activityId for case activities in postProcess hook (CRM-9590 but for cases)
Pages: [1]

Author Topic: activityId for case activities in postProcess hook (CRM-9590 but for cases)  (Read 475 times)

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
activityId for case activities in postProcess hook (CRM-9590 but for cases)
April 26, 2014, 08:50:47 am
I'm running into the same problem as CRM-9590 but for case activities. There's no way to get the activity id of a newly created activity in the postProcess hook. The difference on the case side is the revisioning logic, and I expect there is code out there that uses the fact that $form->_activityId is blank to tell create vs. edit. So instead of just setting _activityId, I'd propose adding a line to the very bottom of CRM_Case_Form_Activity::postProcess() that sets a different variable, like

$this->_currentRevisionActivityId = $activity->id

and then $form->_currentRevisionActivityId can be used in postProcess hooks.

Or am I missing an easier way to get the id? There is hook_post, but I need to get at the form data so want to do it in postProcess.

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: activityId for case activities in postProcess hook (CRM-9590 but for cases)
April 27, 2014, 03:32:19 am
I know the problem, I tend to circumnavigate it by doing a SELECT MAX(id) from the table?
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: activityId for case activities in postProcess hook (CRM-9590 but for cases)
April 28, 2014, 06:57:01 am
Issue #9590 seems to be fixed in version 4.1.0 so it looks the fix dissappeared!
Developer at Edeveloper / CiviCoop

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: activityId for case activities in postProcess hook (CRM-9590 but for cases)
April 28, 2014, 09:56:48 am
I think it works fine for non-case activities, it was just never addressed for case activities.

But I'm suggesting that adding the exact same fix for case activities might cause problems because of the extra complications of revisioning.

The workaround of max(id) will probably work 99.9% of the time, but in the situation where I want to do this that 0.1% of the time where it gives the wrong id would lead to database corruption, so I don't want to rely on it.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • activityId for case activities in postProcess hook (CRM-9590 but for cases)

This forum was archived on 2017-11-26.