2

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);

1
  • Can you edit the question and put the code (including activityparam)
    – Xavier
    Commented May 27, 2015 at 8:52

2 Answers 2

5

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

civicrm_api3('Activity', 'create', array(
  'subject' => 'Hello',
  'case_id' => 123,
  ...
));
3
  • This works. Thanks. Where should have I looked for to find that key 'case_id' ?
    – M Sivani
    Commented May 28, 2015 at 5:02
  • @MSivani click the checkbox to mark this answer correct :).
    – Coleman
    Commented May 28, 2015 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
    Commented May 28, 2015 at 13:37
1

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!!!

2
  • 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
    Commented May 27, 2015 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. Commented May 27, 2015 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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