With case activities, the Activity Create API seems to create a new revision of the activity. Is there a way of using the API to update a case activity without adding a new revision?

My code currently looks like this:

   foreach ($acts as $act) {
     $result = civicrm_api3('Activity', 'create', [
      'return' => ["contact_id", "subject"],
      'id' => $act['id'],
          'custom_114' => $var1,
          'custom_115' => $var2,

I just want to overwrite the contents of custom_114 and custom_115 in each existing activity record, but it seems to create a new revision of each activity, containing the updated values.

API v3
CiviCRM v. 5.10.4

  • You could look at the custom value API perhaps? I'd be tempted just to SQL it, if you know what you're doing and are happy that there will be no side effects. – artfulrobot Feb 11 '20 at 8:40

There is also a setting which AFAIK prevents adding a new revision. The setting is under Administer>System Settings>CiviCase>CiviCase Settings and is called Enable Embedded Activity Revisions

  • Brilliant. That's exactly what I needed. Thank you! – Jern Mar 5 '19 at 11:14

CiviCase was originally designed with HIPPA and related requirements in mind, so it tracks changes.

You could have your code delete the original after making a new one.

You can also turn on advanced logging under admin - system settings - misc. I believe a future goal is to have that logging system, based on triggers, completely replace revisions. I'm not sure if it completely does that yet.

  • I see. Thank you. We also have logging enabled, so I think we'll have to delete the original. Could the deletion be done using a chained api function from the update function, or is that too much to hope for? – Jern Mar 3 '19 at 15:31
  • 1
    I don't think so since it wouldn't be a standard operation. And actually if the delete api call is too smart it might not actually delete it just set is_deleted since it's a case activity. But if it actually deletes it then you'd also want to set original_id to null on the new one too. – Demerit Mar 3 '19 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.