Body: <p>I have a custom field set that is used for cases of a certain case type. Adding a second case type brings up the following popup after saving:</p>
  <blockquote>
  <p>Warning: You have chosen to remove one or more subtypes. This will
  cause any custom data records associated with those subtypes to be
  removed as long as the contact does not have a contact subtype still
  selected.</p>
  </blockquote>
  <p>Confirming it throws the exception:</p>
  <blockquote>
  <p>CRM_Core_Exception: Supplied Sub type is not valid for the specified
  entity in
  /opt/drupal/vendor/civicrm/civicrm-core/CRM/Custom/Form/Group.php on
  line 293</p>
  </blockquote>
  <p>If I do the same on a custom field set for contacts it's fine, When creating a new custom field set for cases and adding the two case types I can save it but when trying to open it again this exception occurs:</p>
  <blockquote>
  <p>CRM_Core_Exception: Expected to find one CustomGroup record, but there
  were zero. in
  /opt/drupal/vendor/civicrm/civicrm-core/Civi/Api4/Generic/Result.php
  on line 90</p>
  </blockquote>
  <p>Seems to me that Civi thinks we are dealing with custom data for contacts here.</p>
  <p>I am on CiviCRM version 5.70.0.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-25T21:48:21.737Z
Comments.Text: What is the Civi version?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-25T21:54:07.277Z
Comments.Text: The version ist 5.70.0.
Comments.UserDisplayName: Jan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2024-03-25T22:40:59.437Z
Comments.Text: I just upgraded to 5.71.1 and it's still there.
Comments.UserDisplayName: Jan
Tags: <custom-fields><civicase>
Title: Exception when adding case type to custom field set
ThreadText: # Exception when adding case type to custom field set
  
  (Asked by: username_0 on 2024-03-25)
  
  I have a custom field set that is used for cases of a certain case type. Adding a second case type brings up the following popup after saving:
  
  > Warning: You have chosen to remove one or more subtypes. This will
  > cause any custom data records associated with those subtypes to be
  > removed as long as the contact does not have a contact subtype still
  > selected.
  
  Confirming it throws the exception:
  
  > CRM\_Core\_Exception: Supplied Sub type is not valid for the specified
  > entity in
  > /opt/drupal/vendor/civicrm/civicrm-core/CRM/Custom/Form/Group.php on
  > line 293
  
  If I do the same on a custom field set for contacts it's fine, When creating a new custom field set for cases and adding the two case types I can save it but when trying to open it again this exception occurs:
  
  > CRM\_Core\_Exception: Expected to find one CustomGroup record, but there
  > were zero. in
  > /opt/drupal/vendor/civicrm/civicrm-core/Civi/Api4/Generic/Result.php
  > on line 90
  
  Seems to me that Civi thinks we are dealing with custom data for contacts here.
  
  I am on CiviCRM version 5.70.0.
  
  **Tags:** custom-fields, civicase
  
  > **Comments:**
  > **username_1**: What is the Civi version?  
  > **username_0**: The version ist 5.70.0.  
  > **username_0**: I just upgraded to 5.71.1 and it's still there.  
  
  ---
  
  ## 0 answers
  
  