I want to create an activity inside a case. I can create a case using $result = civicrm_api3('case', 'create', $params); But how do I pass the case id in the api which creates an Activity. To create Activity I am using: civicrm_api('Activity', 'create', $activityparam);

  • Can you edit the question and put the code (including activityparam)
    – Xavier
    May 27 '15 at 8:52

The param you are looking for is case_id which can be used like:

civicrm_api3('Activity', 'create', array(
  'subject' => 'Hello',
  'case_id' => 123,
  • This works. Thanks. Where should have I looked for to find that key 'case_id' ?
    – M Sivani
    May 28 '15 at 5:02
  • @MSivani click the checkbox to mark this answer correct :).
    – Coleman
    May 28 '15 at 13:26
  • Hmm you're right that param seems a bit hidden. I think it needs to be added to the _civicrm_api3_activity_create_spec function so it will be visible in the api explorer. Here I've created a PR to add it.
    – Coleman
    May 28 '15 at 13:37

you don't have to create an Activity because we already have a table called civicrm_case_activity. Which links the case Id against the new activity created and you can also view the activity against CiviCase Dashboard. I guess this helps!!!

  • Not sure if you are considering the need that I want to create an Activity using API in my custom module. I do not see any parameter key in civicrm_api('Activity', 'create', $activityparam); to pass the case id.
    – M Sivani
    May 27 '15 at 9:11
  • yes, you cannot pass case Id while creating the activity but you can create an activity and make a entry in civicrm_case_activity which will link the created activity again the case Id. May 27 '15 at 9:54

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.