CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Separate contact types with shared custom fields
Pages: [1]

Author Topic: Separate contact types with shared custom fields  (Read 548 times)

ThomWilhelm

  • I’m new here
  • *
  • Posts: 10
  • Karma: 2
  • CiviCRM version: 4.2
  • CMS version: Drupal
  • MySQL version: 5
  • PHP version: 5
Separate contact types with shared custom fields
November 06, 2012, 02:52:21 am
I have 2 contact subtypes, "Subtype A" and "Subtype B". They both share use the same custom fields, "Custom Fields A".

However when I remove "Subtype A" from a contact and select "Subtype B", 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. Click OK to proceed, or Cancel to review your changes before saving."

It seems Civi doesn't detect that the subtypes shares exactly the same custom data, and as a result no data is lost which is good. I'm just wondering if there is any way to be more intelligent about the way this message is displayed?

Code: [Select]
function warnSubtypeDataLoss( )
{
   var submittedSubtypes = cj('#contact_sub_type').val();
   var defaultSubtypes   = {/literal}{$oldSubtypes}{literal};

   var warning = false;
   cj.each(defaultSubtypes, function(index, subtype) {
      if ( cj.inArray(subtype, submittedSubtypes) < 0 ) {
         warning = true;
      }
   });

   if ( warning ) {
      return confirm( '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. Click OK to proceed, or Cancel to review your changes before saving.' );
   }
   return true;
}

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Separate contact types with shared custom fields
November 06, 2012, 06:24:35 am

Seems like the code will need to tell the template which subtypes share ALL the custom data and hence no data loss. Do you want to take a look at the code and give that a shot

seems like an edge case though

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Separate contact types with shared custom fields

This forum was archived on 2017-11-26.