Answers.Body: <p>The commentary suggests that the history of this case-type may have allowed some weird data in.</p>
  
  <p>In case one did want to dig in more, a couple debug tricks that might be interesting:</p>
  
  <ul>
  <li>Open the case-type admin UI and edit the current URL to append <code>?angularDebug=1</code>. This will cause it to display a panel with the "live" content of the CaseType and its definition. This is available in most Angular pages.</li>
  <li>If you're experimenting on a dev/staging site, you might try unsetting the definition via SQL (<code>UPDATE civicrm_case_type SET definition = NULL where id = ...</code>). This is sometimes useful for forcibly revertig a definition (even if the UI is misbehaved).</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T19:35:13.987Z
Answers.LastActivityDate: 2015-09-27T19:35:13.987Z
Answers.UserDisplayName: Tim Otten
Answers.Body: <p>I've found the same thing happening, but in our case it was because of an overridden <code>CaseType.php</code> file. It's possible to reproduce in older CiviCRM versions by saving a case type that contains an activity type with <code>&amp;</code> in the name. This will be saved to the database, but when you try to edit it in the UI the ampersand (a reserved character) breaks the XML schema and the UI won't show a standard timeline. Pressing save on this screen will result in the dummy XML you mentioned in the problem:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  
  &lt;CaseType&gt;
  &lt;name&gt;engagement&lt;/name&gt;
  &lt;/CaseType&gt;
  </code></pre>
  
  <p>This was fixed a long time ago in <a href="https://issues.civicrm.org/jira/browse/CRM-16360" rel="nofollow noreferrer">CRM-16360</a> so shouldn't be a problem anymore.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-21T09:12:17.713Z
Answers.LastActivityDate: 2017-08-21T09:12:17.713Z
Answers.UserDisplayName: mickadoo
Answers.Body: <p>Does it work to just delete the offending files?</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-29T20:21:49.967Z
Answers.Text: D'you mean case xml files? There are none for the offending case types, they seem to have been created since the 4.6 upgrade, when case type setup became possible through the UI.
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-29T22:56:35.207Z
Answers.Text: Do you have any case types that are functioning correctly?  Are there any cases tied to those misbehaving case types?
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T11:27:37.023Z
Answers.Text: Yes, there are other case types functioning correctly and I can create new ones.  And yes, there are cases of the misbehaving case types.
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-30T15:00:02.203Z
Answers.Text: A little more info has come in from the user: they say they created at least one of the misbehaving case types themselves, before the upgrade (so on 4.4), despite not having access to create xml files!
  So it could be that this case type at least was never set up properly. If that's so, I'm surprised that they were able to create cases of that type in 4.4, I would have expected errors saying the xml file is missing. I'll update here if more info emerges.
  The inability to add activity types or timelines to these case types in 4.6 & the lack of error messages still needs tracking down I think.
Answers.UserDisplayName: davejenx
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-27T21:53:55.627Z
Answers.Text: This doesn't qualify as debugging, but I have seen were improperly created old case types (prior to the shiny CiviCase UI) hung around and caused some issues.  We ended up recreating the case types in the ui, moving the cases to the new types and deleting traces to the old ones.  In the end we did it for all case types so we didn't have to deal with the extra work involved with the xml files.  If i remember correctly, at the time of the ui improvement, there were some questions about the old xml files and whether or not we still needed them.
Answers.UserDisplayName: pmoz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-29T17:13:31.670Z
Answers.LastActivityDate: 2015-07-29T17:13:31.670Z
Answers.UserDisplayName: Coleman
Body: <p>On a particular Civi 4.6.4 / Drupal 7 installation, recently upgraded from 4.4, there are some misbehaving case types. They appear to have been created through the CiviCase UI since the 4.6 upgrade, as there are no corresponding xml files in <code>CRM/Case/xml/configuration/</code> under the custom template directory. These case types have no activity types and no timeline specified. The xml in the <code>definition</code> field of the civicrm_case table is just this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  
  &lt;CaseType&gt;
  &lt;name&gt;engagement&lt;/name&gt;
  &lt;/CaseType&gt;
  </code></pre>
  
  <p>When I try to edit one of these broken case types through the UI, e.g. adding activity types or adding a standard timeline containing Open Case, it does not save. No error is reported on screen, in CiviCRM.blah.log, Drupal watchdog, Firebug console or the web server error log.</p>
  
  <p>The following civicrm/ajax/rest call is shown in Firebug on saving:</p>
  
  <pre><code>action: create
  entity: CaseType
  json: {"id":"4","name":"engagement","title":"Engagement","is_active":"1","is_reserved":"0","weight":"2","definition":[],"is_forkable":"1","is_forked":""}
  </code></pre>
  
  <p>Note <code>"definition":[]</code>. This I assume should hold details of the activity types &amp; timeline I have just attempted to add. The response is as expected, given the data that was provided:</p>
  
  <pre><code>{"is_error":0,"version":3,"count":1,"id":4,"values":{"4":{"id":"4","name":"engagement","title":"Engagement","description":"","is_active":"1","is_reserved":"0","weight":"2","definition":[],"is_forkable":"1","is_forked":""}}}
  </code></pre>
  
  <p>However I was able to create a new case type OK.</p>
  
  <p>Any advice on debugging this would be much appreciated.</p>
  
Tags: <civicase>
Title: Case type edit not saving, broken case types - how to debug?
ThreadText: # Case type edit not saving, broken case types - how to debug?
  
  (Asked by: username_0 on 2015-07-29)
  
  On a particular Civi 4.6.4 / Drupal 7 installation, recently upgraded from 4.4, there are some misbehaving case types. They appear to have been created through the CiviCase UI since the 4.6 upgrade, as there are no corresponding xml files in CRM/Case/xml/configuration/ under the custom template directory. These case types have no activity types and no timeline specified. The xml in the definition field of the civicrm_case table is just this:
  
  
  
  engagement
  
  
  When I try to edit one of these broken case types through the UI, e.g. adding activity types or adding a standard timeline containing Open Case, it does not save. No error is reported on screen, in CiviCRM.blah.log, Drupal watchdog, Firebug console or the web server error log.
  The following civicrm/ajax/rest call is shown in Firebug on saving:
  action: create
  entity: CaseType
  json: {"id":"4","name":"engagement","title":"Engagement","is_active":"1","is_reserved":"0","weight":"2","definition":[],"is_forkable":"1","is_forked":""}
  
  Note "definition":[]. This I assume should hold details of the activity types & timeline I have just attempted to add. The response is as expected, given the data that was provided:
  {"is_error":0,"version":3,"count":1,"id":4,"values":{"4":{"id":"4","name":"engagement","title":"Engagement","description":"","is_active":"1","is_reserved":"0","weight":"2","definition":[],"is_forkable":"1","is_forked":""}}}
  
  However I was able to create a new case type OK.
  Any advice on debugging this would be much appreciated.
  
  **Tags:** civicase
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2015-09-27. Score: 2
  
  The commentary suggests that the history of this case-type may have allowed some weird data in.
  
  In case one did want to dig in more, a couple debug tricks that might be interesting:
  
  * Open the case-type admin UI and edit the current URL to append `?angularDebug=1`. This will cause it to display a panel with the "live" content of the CaseType and its definition. This is available in most Angular pages.
  * If you're experimenting on a dev/staging site, you might try unsetting the definition via SQL (`UPDATE civicrm_case_type SET definition = NULL where id = ...`). This is sometimes useful for forcibly revertig a definition (even if the UI is misbehaved).
  
  
  ---
  
  ### Answer by username_2 on 2017-08-21. Score: 1
  
  I've found the same thing happening, but in our case it was because of an overridden CaseType.php file. It's possible to reproduce in older CiviCRM versions by saving a case type that contains an activity type with & in the name. This will be saved to the database, but when you try to edit it in the UI the ampersand (a reserved character) breaks the XML schema and the UI won't show a standard timeline. Pressing save on this screen will result in the dummy XML you mentioned in the problem:
  
  
  
  engagement
  
  
  This was fixed a long time ago in CRM-16360 so shouldn't be a problem anymore.
  
  
  ---
  
  ### Answer by username_3 on 2015-07-29. Score: 0
  
  Does it work to just delete the offending files?
  
  > **Comments:**
  > **username_0**: D'you mean case xml files? There are none for the offending case types, they seem to have been created since the 4.6 upgrade, when case type setup became possible through the UI.  
  > **username_4**: Do you have any case types that are functioning correctly?  Are there any cases tied to those misbehaving case types?  
  > **username_0**: Yes, there are other case types functioning correctly and I can create new ones.  And yes, there are cases of the misbehaving case types.  
  > **username_0**: A little more info has come in from the user: they say they created at least one of the misbehaving case types themselves, before the upgrade (so on 4.4), despite not having access to create xml files! So it could be that this case type at least was never set up properly. If that's so, I'm surprised that they were able to create cases of that type in 4.4, I would have expected errors saying the xml file is missing. I'll update here if more info emerges. The inability to add activity types or timelines to these case types in 4.6 & the lack of error messages still needs tracking down I think.  
  > **username_4**: This doesn't qualify as debugging, but I have seen were improperly created old case types (prior to the shiny CiviCase UI) hung around and caused some issues.  We ended up recreating the case types in the ui, moving the cases to the new types and deleting traces to the old ones.  In the end we did it for all case types so we didn't have to deal with the extra work involved with the xml files.  If i remember correctly, at the time of the ui improvement, there were some questions about the old xml files and whether or not we still needed them.  
  
  ---
  
  