Answers.Body: <p>The EntityRef field on the form can be given that restriction. Best way to do it is probably via a hook, e.g.</p>
  
  <pre><code>hook_civicrm_preProcess($formName, &amp;$form) {
    if (is_a($form, 'CRM_Activity_Form_Activity')) {
      $form-&gt;_fields['assignee_contact_id']['attributes']['api']['params']['group'] = 1;
    }
  }
  </code></pre>
  
  <p>(where "hook" is the name of your module and "1" is the id of the group)</p>
  
  <p>Note use of <code>is_a</code> rather than the <code>$formName</code> so we also catch the case activity form.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-11-23T15:57:20.287Z
Answers.LastActivityDate: 2018-11-18T03:48:18.067Z
Answers.LastEditDate: 2018-11-18T03:48:18.067Z
Answers.UserDisplayName: Coleman
Body: <p>We're looking to restrict the contacts that are available when assigning an activity. Has anyone done this before?</p>
  
  <p>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.</p>
  
  <p>It would be great if this could be restricted by group the same was a custom contact reference field can be done.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-14T17:36:40.457Z
Comments.Text: What CMS? If Drupal then Webforms can probably give you the required feature
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-16T09:16:44.127Z
Comments.Text: 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!)
Comments.UserDisplayName: Heather O.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-16T19:30:50.723Z
Comments.Text: right. understood
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-16T19:31:19.357Z
Comments.Text: are you able to accept Coleman's answer and close this off?
Comments.UserDisplayName: petednz - fuzion
Tags: <activities><groups>
Title: Restrict contacts available to be assigned to an activity
ThreadText: # Restrict contacts available to be assigned to an activity
  
  (Asked by: username_0 on 2015-11-23)
  
  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.
  
  **Tags:** activities, groups
  
  > **Comments:**
  > **username_1**: What CMS? If Drupal then Webforms can probably give you the required feature  
  > **username_0**: 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!)  
  > **username_1**: right. understood  
  > **username_1**: are you able to accept username_2's answer and close this off?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-11-23. Score: 5
  
  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.
  
  
  ---
  
  