We're looking to restrict the contacts that are available when assigning an activity. Has anyone done this before?

The email function is really useful, but due to the sensitive nature of some of the information, we want to remove the possibility of human error as someone could accidentally choose the wrong contact to assign.

It would be great if this could be restricted by group the same was a custom contact reference field can be done.

  • What CMS? If Drupal then Webforms can probably give you the required feature
    – petednz - fuzion
    Nov 14, 2018 at 17:36
  • The team are really used to the CiviCRM UI for this work. There are lots of custom data sets linked to specfic activity types, so we would have to build a lot of webforms with lots of different logic, which would be really difficult to manage long term. So unfortunately, webforms wouldn't be the best solution in this case (although I love webforms and use them all the time!)
    – Heather O.
    Nov 16, 2018 at 9:16
  • right. understood
    – petednz - fuzion
    Nov 16, 2018 at 19:30
  • are you able to accept Coleman's answer and close this off?
    – petednz - fuzion
    Nov 16, 2018 at 19:31

1 Answer 1


The EntityRef field on the form can be given that restriction. Best way to do it is probably via a hook, e.g.

hook_civicrm_preProcess($formName, &$form) {
  if (is_a($form, 'CRM_Activity_Form_Activity')) {
    $form->_fields['assignee_contact_id']['attributes']['api']['params']['group'] = 1;

(where "hook" is the name of your module and "1" is the id of the group)

Note use of is_a rather than the $formName so we also catch the case activity form.

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.