When you assign a case role through the UI it creates lines in the relationships and activities tables. I can't find an equivalent through the API - I can create the relationship (which then shows correctly in the case UI), but it doesn't create any activity lines. Does that matter? Or is there a better way?

Edit: Running on Civi 4.5.8 on WordPress.



  • What version of CiviCRM are you working with?
    – DaveD
    Nov 6, 2015 at 21:02
  • 4.5.8 - have updated the question too. Nov 6, 2015 at 21:16

1 Answer 1


Looking through the api code for relationships it doesn't appear to be case-aware. You can duplicate what happens in the UI by checking out CRM_Contact_Page_Ajax::relationship(), and note near the bottom where it calls CRM_Case_BAO_Case::createCaseRoleActivity().

Depending on what you mean by "api", that might not be exactly what you're looking for, but you should just be able to add a call to CRM_Case_BAO_Case::createCaseRoleActivity() to the code you've written that already creates the relationship.

  • brill - thank you for digging into the code on that one. Nov 9, 2015 at 19:55

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.