1

Gurus, it seems that api3

civicrm_api3('Activity', 'create', [
  'id' => 1234,
  'case_id' => 12,
]);

does not assign the activity to the case. From my reading of funtion civicrm_api3_activity_create($params), I can imagine that it depends on enabling the CiviCase setting "Enable deprecated Embedded Activity Revisions" and it won't work without it by design. Could that be?

I came across this problem when testing the api because Dataprocessor resp. the ActionProvider extensions expose and use the api param case_id without effect.

My use case is a dataprocessor which processes an event registration which has to be assigned to as case.

CiviCRM is v5.37.2

2

It's not an "api" exactly, but you can use:

      $caseParams = [
        'activity_id' => 1234,
        'case_id' => 12,
      ];
      CRM_Case_BAO_Case::processCaseActivity($caseParams);

Are you saying the api call used to work before and now is failing? I'm not sure if it ever worked before with an existing activity?

It looks also like in api4 you can do:

\Civi\Api4\CaseActivity::create()
  ->addValue('activity_id', 1234)
  ->addValue('case_id', 12)
  ->execute();
3
  • Thanks @Demerit, I'll edit and clarify my post.
    – nielo
    Aug 24 at 12:03
  • Would CRM_Case_BAO_Case::processCaseActivity($caseParams) inside a drupal module work after bootstrapping civicrm?
    – nielo
    Aug 24 at 12:26
  • 1
    Yes I've used it that way before (in drupal 7 at least).
    – Demerit
    Aug 24 at 12:52

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.