Answers.Body: <p>Technically it's the permission "access all cases and activities" that can add roles on Manage Case but I guess that's the same as "site admin"/"full access" in your setup. The reason seems to be to avoid a loophole where access to cases could be granted that shouldn't be (see <a href="https://civicrm.stackexchange.com/a/33409/181">https://civicrm.stackexchange.com/a/33409/181</a>).</p>
  
  <p>Anyway what you might be able to do is tag or group the people who should all be case managers for a given local site, and then using hook_postProcess or hook_post add some code that automatically adds those roles when a new case is created for people who have the same tag/group as the case creator, i.e.</p>
  
  <pre><code>loop for each person with the same tag/group as the logged in user:
  civicrm_api3('Relationship', 'create', [
    'contact_id_a' =&gt; 123, // client id
    'contact_id_b' =&gt; 194, // other person's id
    'relationship_type_id' =&gt; 9, // Case Coordinator is
    'case_id' =&gt; 12345,
  ]);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-06T15:22:56.867Z
Answers.Text: I've also noticed that users without 'access all cases' cannot see resolved/closed cases - can this be adapted in a similar way?
Answers.UserDisplayName: Rose Lanigan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-06T15:27:14.433Z
Answers.Text: That's probably related to some ongoing known issues with relationships when a case closes. There's a couple lab tickets / stalled PRs still open. But you could do a local customization, just note it also currently affects what appears on the case dashboard when you change the behavior. This is one reason it's hard to fix because changing one thing changes three other things.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-06T14:52:42.967Z
Answers.LastActivityDate: 2019-11-06T14:52:42.967Z
Answers.UserDisplayName: Demerit
Body: <p>I've got a multi-site with the following roles in Drupal:</p>
  
  <ul>
  <li>Site admin (full access)</li>
  <li>Local admin (can view all contacts)</li>
  <li>Case Manager (can view all Cases)</li>
  <li>Staff (using ACLs, can view site-specific contacts and no Cases)</li>
  </ul>
  
  <p>We want to restrict the Case Managers so that they can only see the Cases on their own site, even if they also have 'Local admin' (view all contacts).</p>
  
  <p>I've only managed to implement so far by adding all Case Managers as 'Coordinators' to every Case in their local site, so that the 'View my Cases' enables them to see the local Cases.</p>
  
  <p>This is fine, however I cannot work out how Case Managers can then add more than one Case Coordinator for new Cases.</p>
  
  <ul>
  <li>Using the Drupal webform, I can only specify a single contact for Case Coordinator (regardless of permissions)</li>
  <li>In the normal Case Dashboard, only people with 'Site Admin' (i.e. full access) have the ability to add more Roles to a Case</li>
  <li>In the Case Type set-up, it only allows one of each relationship type for the default set up.</li>
  </ul>
  
  <p>Is there a way to enable staff to either see all Cases for their local instance <em>only</em> or to enable them to manually add more than one Case Coordinator so that the three staff can see all Cases for their local site?</p>
  
Tags: <webform-civicrm><civicase><permissions>
Title: Adding multiple Case Coordinators in a Drupal webform?
ThreadText: # Adding multiple Case Coordinators in a Drupal webform?
  
  (Asked by: username_0 on 2019-11-06)
  
  I've got a multi-site with the following roles in Drupal:
  
  * Site admin (full access)
  * Local admin (can view all contacts)
  * Case Manager (can view all Cases)
  * Staff (using ACLs, can view site-specific contacts and no Cases)
  
  We want to restrict the Case Managers so that they can only see the Cases on their own site, even if they also have 'Local admin' (view all contacts).
  
  I've only managed to implement so far by adding all Case Managers as 'Coordinators' to every Case in their local site, so that the 'View my Cases' enables them to see the local Cases.
  
  This is fine, however I cannot work out how Case Managers can then add more than one Case Coordinator for new Cases.
  
  * Using the Drupal webform, I can only specify a single contact for Case Coordinator (regardless of permissions)
  * In the normal Case Dashboard, only people with 'Site Admin' (i.e. full access) have the ability to add more Roles to a Case
  * In the Case Type set-up, it only allows one of each relationship type for the default set up.
  
  Is there a way to enable staff to either see all Cases for their local instance *only* or to enable them to manually add more than one Case Coordinator so that the three staff can see all Cases for their local site?
  
  **Tags:** webform-civicrm, civicase, permissions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-11-06. Score: 1
  
  Technically it's the permission "access all cases and activities" that can add roles on Manage Case but I guess that's the same as "site admin"/"full access" in your setup. The reason seems to be to avoid a loophole where access to cases could be granted that shouldn't be (see <https://civicrm.stackexchange.com/a/33409/181>).
  
  Anyway what you might be able to do is tag or group the people who should all be case managers for a given local site, and then using hook\_postProcess or hook\_post add some code that automatically adds those roles when a new case is created for people who have the same tag/group as the case creator, i.e.
  
  ```
  loop for each person with the same tag/group as the logged in user:
  civicrm_api3('Relationship', 'create', [
    'contact_id_a' => 123, // client id
    'contact_id_b' => 194, // other person's id
    'relationship_type_id' => 9, // Case Coordinator is
    'case_id' => 12345,
  ]);
  
  ```
  
  > **Comments:**
  > **username_0**: I've also noticed that users without 'access all cases' cannot see resolved/closed cases - can this be adapted in a similar way?  
  > **username_1**: That's probably related to some ongoing known issues with relationships when a case closes. There's a couple lab tickets / stalled PRs still open. But you could do a local customization, just note it also currently affects what appears on the case dashboard when you change the behavior. This is one reason it's hard to fix because changing one thing changes three other things.  
  
  ---
  
  