Answers.Body: <p>It seems to be problem with data how its saved in database. The settings for Custom group might have been corrupted during upgrade or some scenario are not being handle during upgrade. To debug or fix this you will need to do some troubleshooting</p>
  
  <ol>
  <li><p>Check each Individual and sub types custom groups and re save the settings for each such custom groups so that the settings are saved correctly.</p></li>
  <li><p>Check when updating contacts does the data from all custom data gets deleted or only the subtypes</p></li>
  <li><p>Check if Contact subtype are pre populated correctly on edit screen of contact and also Custom group fieldsets gets loaded of subtype and non subtype.</p></li>
  <li><p>Put debug statements to check what values are loaded in smarty variables for <code>$oldSubtypes</code></p></li>
  </ol>
  
  <p>HTH</p>
  
  <p>Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-28T15:55:15.490Z
Answers.LastActivityDate: 2018-01-28T15:55:15.490Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I first posted this issue under another question (<a href="https://civicrm.stackexchange.com/questions/22436/after-upgrade-cant-edit-contact-details-fields-custom-addressee-and-de-select">after upgrade, can&#39;t edit Contact Details fields (Custom Addressee and de-selected subtypes errors)</a>) thinking two separate issues were related. But apparently they aren't.  Since a kind soul correctly solved one of my issues, I marked his answer accepted. But one issue still isn't resolved, I decided to open a new question just for it.</p>
  
  <p>I have upgraded a site from an older CiviCRM version (4.4) to 4.7.29.  And now I can't edit the Contact Detail fields for any record with a specific custom subtype.</p>
  
  <p>I have a type named "Member", which is a subtype of the "Individual" contact type.  When I open one of these records in the backend, I get the following warning:</p>
  
  <pre><code>"One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed as long as the contact does not have a contact subtype still selected. Click OK to proceed, or Cancel to review your changes before saving."
  </code></pre>
  
  <p>If I click "OK" to continue saving, the record does save -- but all of the data associated with the custom subtype "Member" is deleted.</p>
  
  <p>Here's what I know so far:</p>
  
  <p>-- This problem only occurs with the one custom subtype I've created.  Other custom subtypes under "Organization" don't have this problem.</p>
  
  <p>-- This problem only occurs in the administrative backend contact record screens.  Profiles that are used in the website frontend update all details for this contact subtype without problems.</p>
  
  <p>-- The custom subtype does appear correctly in the "Contact Type" field for the record.</p>
  
  <p>-- Searching for contacts with this contact subtype works correctly and returns all the right data.</p>
  
  <p>-- Creating a new record of this subtype works just fine. However, afterwards trying to save the new record has the same problem.</p>
  
  <p>-- I've confirmed this error is thrown by the file /civicrm/templates/CRM/Contact/Form/Contact.tpl where the Javascript does this check at line 228:</p>
  
  <pre><code>{if $oldSubtypes}{literal}
      $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() {
        var submittedSubtypes = $('#contact_sub_type').val();
        var oldSubtypes = {/literal}{$oldSubtypes}{literal};
  
        var warning = false;
        $.each(oldSubtypes, function(index, subtype) {
          if ( $.inArray(subtype, submittedSubtypes) &lt; 0 ) {
            warning = true;
          }
        });
        if ( warning ) {
          return confirm({/literal}'{ts escape="js"}One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed as long as the contact does not have a contact subtype still selected. Click OK to proceed, or Cancel to review your changes before saving.{/ts}'{literal});
        }
        return true;
      });
      {/literal}{/if}
  </code></pre>
  
  <p>So.....it seems that one of my legacy custom contact types is no longer recognized by <strong>some</strong> part of CiviCRM, but it <strong>IS</strong> still recognized by some parts of CiviCRM?  Help!</p>
  
Tags: <contacts><error><sub-types>
Title: can't edit Contact Details for records with a custom subtype (Error: One or more contact subtypes have been de-selected from the list ...")
ThreadText: # can't edit Contact Details for records with a custom subtype (Error: One or more contact subtypes have been de-selected from the list ...")
  
  (Asked by: username_0 on 2018-01-28)
  
  I first posted this issue under another question (after upgrade, can't edit Contact Details fields (Custom Addressee and de-selected subtypes errors)) thinking two separate issues were related. But apparently they aren't.  Since a kind soul correctly solved one of my issues, I marked his answer accepted. But one issue still isn't resolved, I decided to open a new question just for it.
  I have upgraded a site from an older CiviCRM version (4.4) to 4.7.29.  And now I can't edit the Contact Detail fields for any record with a specific custom subtype.
  I have a type named "Member", which is a subtype of the "Individual" contact type.  When I open one of these records in the backend, I get the following warning:
  "One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed as long as the contact does not have a contact subtype still selected. Click OK to proceed, or Cancel to review your changes before saving."
  
  If I click "OK" to continue saving, the record does save -- but all of the data associated with the custom subtype "Member" is deleted.
  Here's what I know so far:
  -- This problem only occurs with the one custom subtype I've created.  Other custom subtypes under "Organization" don't have this problem.
  -- This problem only occurs in the administrative backend contact record screens.  Profiles that are used in the website frontend update all details for this contact subtype without problems.
  -- The custom subtype does appear correctly in the "Contact Type" field for the record.
  -- Searching for contacts with this contact subtype works correctly and returns all the right data.
  -- Creating a new record of this subtype works just fine. However, afterwards trying to save the new record has the same problem.
  -- I've confirmed this error is thrown by the file /civicrm/templates/CRM/Contact/Form/Contact.tpl where the Javascript does this check at line 228:
  {if $oldSubtypes}{literal}
      $('input[name=_qf_Contact_upload_view], input[name=_qf_Contact_upload_new]').click(function() {
        var submittedSubtypes = $('#contact_sub_type').val();
        var oldSubtypes = {/literal}{$oldSubtypes}{literal};
  
        var warning = false;
        $.each(oldSubtypes, function(index, subtype) {
          if ( $.inArray(subtype, submittedSubtypes) < 0 ) {
            warning = true;
          }
        });
        if ( warning ) {
          return confirm({/literal}'{ts escape="js"}One or more contact subtypes have been de-selected from the list for this contact. Any custom data associated with de-selected subtype will be removed as long as the contact does not have a contact subtype still selected. Click OK to proceed, or Cancel to review your changes before saving.{/ts}'{literal});
        }
        return true;
      });
      {/literal}{/if}
  
  So.....it seems that one of my legacy custom contact types is no longer recognized by some part of CiviCRM, but it IS still recognized by some parts of CiviCRM?  Help!
  
  **Tags:** contacts, error, sub-types
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-01-28. Score: 1
  
  It seems to be problem with data how its saved in database. The settings for Custom group might have been corrupted during upgrade or some scenario are not being handle during upgrade. To debug or fix this you will need to do some troubleshooting
  
  1. Check each Individual and sub types custom groups and re save the settings for each such custom groups so that the settings are saved correctly.
  2. Check when updating contacts does the data from all custom data gets deleted or only the subtypes
  3. Check if Contact subtype are pre populated correctly on edit screen of contact and also Custom group fieldsets gets loaded of subtype and non subtype.
  4. Put debug statements to check what values are loaded in smarty variables for `$oldSubtypes`
  
  HTH
  
  Pradeep
  
  
  ---
  
  