Answers.Body: <p>Futher investigation has given me at least one answer. I can create my own template file with new jQuery functions using my new function as a callback. In that new jQuery function I can replace the .onClick functions for the button 'add Role' and the edit pencil. But still open to better suggestions!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-30T13:55:20.270Z
Answers.LastActivityDate: 2015-04-30T13:55:20.270Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>I have a customer where it is vital that there is only one Case Role on a case. In the CaseView form it is possible to add a case role, and I want to add some validation to this.
  in core actual processing is done in a jQuery function, with the callback function at CRM_Contact_Page_AJAX::relation.</p>
  
  <p>I can do nothing with a validateForm hook here, so what I am planning to do is:</p>
  
  <ol>
  <li>create a 'dummy' page with my own version of CRM_Contact_Page_AJAX::relation with the desired validation included</li>
  <li>replace the template for CaseView with a local version, linking to the new function with the alterTemplate hook</li>
  </ol>
  
  <p>Unfortunately this solution is not viable for a true generic extension. Any better ideas? If not, I will add the instruction to the README and still publish the extension as it might be useful for others too but I wonder if there is a better way.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-04-30T13:49:46.633Z
Comments.Text: Whilst doing this I ofcourse found that I can not use the alterTemplateFile hook as CaseView is a Page rather than a Form....
Comments.UserDisplayName: ErikH - CiviCooP
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-30T17:15:22.303Z
Comments.Text: Is it that you want one and only one case role per case, or one of *each* role. I'm not quite sure how it can be the former because technically "Case creator" and "Case client" are both roles, so a freshly created case will already have 2.
Comments.UserDisplayName: Coleman
Tags: <extension><civicase><developer>
Title: How to add validation to the 'Add Case Role' option in Case Summary View?
ThreadText: # How to add validation to the 'Add Case Role' option in Case Summary View?
  
  (Asked by: username_0 on 2015-04-30)
  
  I have a customer where it is vital that there is only one Case Role on a case. In the CaseView form it is possible to add a case role, and I want to add some validation to this.
  in core actual processing is done in a jQuery function, with the callback function at CRM\_Contact\_Page\_AJAX::relation.
  
  I can do nothing with a validateForm hook here, so what I am planning to do is:
  
  1. create a 'dummy' page with my own version of CRM\_Contact\_Page\_AJAX::relation with the desired validation included
  2. replace the template for CaseView with a local version, linking to the new function with the alterTemplate hook
  
  Unfortunately this solution is not viable for a true generic extension. Any better ideas? If not, I will add the instruction to the README and still publish the extension as it might be useful for others too but I wonder if there is a better way.
  
  **Tags:** extension, civicase, developer
  
  > **Comments:**
  > **username_0**: Whilst doing this I ofcourse found that I can not use the alterTemplateFile hook as CaseView is a Page rather than a Form....  
  > **username_1**: Is it that you want one and only one case role per case, or one of *each* role. I'm not quite sure how it can be the former because technically "Case creator" and "Case client" are both roles, so a freshly created case will already have 2.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2015-04-30. Score: 1
  
  Futher investigation has given me at least one answer. I can create my own template file with new jQuery functions using my new function as a callback. In that new jQuery function I can replace the .onClick functions for the button 'add Role' and the edit pencil. But still open to better suggestions!
  
  
  ---
  
  