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) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Custom fields exhibit strange behaviour
Pages: [1]

Author Topic: Custom fields exhibit strange behaviour  (Read 2127 times)

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Custom fields exhibit strange behaviour
October 18, 2012, 03:43:53 am
Not sure if this is related to the recent upgrade to 4.2.2 but my 'test' deployment of CiviCRM is behaving very oddly. Values in custom fields are not being saved when the entity (either an activity, contact or a case) is first submitted or subsequently edited through the main edit function - but the values are saved if the custom field set is clicked on to 'add or edit custom set' directly.

Is this something that anyone else has noticed? What can I do? No error is reported, and no error log either.
« Last Edit: October 19, 2012, 08:07:46 am by nickholden »

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Following upgrade to 4.2.2 custom fields exhibit strange behaviour
October 19, 2012, 03:47:51 am
Hmm, that sounds odd. Can you upgrade to 4.2.4 and see if that helps?
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Following upgrade to 4.2.2 custom fields exhibit strange behaviour
October 19, 2012, 06:17:30 am
I'm doing some more investigation. It is happening in two different installs, one using 4.2.1 and one using 4.2.2 so I don't think it is version specific. I will try an upgrade to 4.2.4 and check there also.

In the meantime, I've verified that it isn't a mysql error, it is a failure to submit the data at all. The form is correctly displayed, and the column references and such like are correct. But data submitted during the form submission are simply lost and not written to the database, while data in other parts of the form are correctly created or updated.

However, it only occurs in relation to custom field sets which extend a sub-set of data. I have set up a test environment in which there are three field sets which extend contacts: one extends any Contact, one extends any Individual, and one extends Individuals of a specific sub-type. Entering data in the contact creation form for fields in all three field sets generates a data submission to the fields in the first set (the set which extends ALL contacts) but not those field sets which extend Individuals only or a specific sub-type only.

By comparison, a field set which extends a sub-type of an Organisation contact works fine in every case. So does a field set which extends addresses.

Behaviour for a field set which extends Cases is not consistent. I have seen instances where the submitted data is not passed to the database, and some where it is, and I haven't yet been able to clarify what the differences are. Sorry.

Using the 'pop out' AJAX data-entry forms for a specific field set works correctly in every case.

I'm looking at the database, and seeing weird special characters in the extends_entity_column_value column - this is true for field sets which I create manually through the civicrm interface or through the API (CustomGroup,create,v3). I realise that this might be normal behaviour, and I will carry on trying to narrow this down, but if my report rings a bell with anyone I'd appreciate any thoughts it triggers.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Following upgrade to 4.2.2 custom fields exhibit strange behaviour
October 19, 2012, 08:06:47 am
I've tried this in 4.2.4 and the problem is still there. Increasingly I think this is not a version-specific problem.

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Custom fields exhibit strange behaviour
October 19, 2012, 09:34:43 am
I did a quick check of above mentioned data sets but can't get any clues for what could be going wrong in your case.

Make sure drupal / php is not suppressing any errors / displaying all errors.

Sometimes its other errors / warnings that might not seem related but causes such strange behaviors. And logs does help identifying such warnings / errors.

Also look for any js errors or using a default theme etc.

Quote
and seeing weird special characters in the extends_entity_column_value column
Yes its normal to be seeing a special char between and around sub-types.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Custom fields exhibit strange behaviour
October 19, 2012, 09:43:09 am
Thanks, Deepak.

I've narrowed things down futher. The problem is somehow related to the sub-types which I have created using the API. When custom field sets are associated with a manually-created sub-type then the edit screen correctly records the data. When the custom field sets are associated with a sub-type created using the API then the edit screen does not save the custom field data.

It doesn't seem to matter whether the custom group is created by hand or by API. But it matters about the underlying contact sub-type.

However, I cannot see any difference in the civicrm_contact_type table between those sub-types created by hand, and those created by the API. Is there another database table in which attributes of the contact sub-types is being stored, in which there may be a difference?

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Custom fields exhibit strange behaviour
October 22, 2012, 01:44:22 am
Hey Nick,

Have you had any further progress on this ? We tried doing some quick checks with apis without any success.

If you could give us steps to reproduce like -

- what exact apis you used and how you created it.

- how did you create same thing from UI.

- and on what url you observing the weird problem.

- are you able to reproduce the problem by repeating above steps on latest install ? If not, what civicrm version you upgraded from and created most of the custom fields from apis.

would help us catch the problem.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Custom fields exhibit strange behaviour
October 22, 2012, 02:31:32 am
Thanks, Deepak. Really appreciate your help. I'm still baffled.

- what exact apis you used and how you created it.

Code: [Select]
# We call a wrapper function like this...
create_civi_contact_subtype(array("name" => "LCBRU Staff", "parent_id" => "1", "description" => "Staff working for the LCBRU.")); // Create sub-type: LCBRU staff

#utility function to create civi contact subtype
function create_civi_contact_subtype($params) {
  civicrm_initialize();
  $params['version']='3';
  $cs = civicrm_api('ContactType','get',$params);
  if ($cs['is_error']) {
    throw new Exception("Error looking for contact type:".$cs['error_message']);
}
  if ($cs['count']==0) {
    $cs = civicrm_api('ContactType','create',$params);
    if ($cs['is_error']) {
      throw new Exception("Error creating contact type:".$cs['error_message']);
}
  } else {
      throw new Exception("Contact type already exists.");
  }
  return array_shift($cs['values']);
}



- how did you create same thing from UI.

http://localhost/drupal-7.15/civicrm/admin/options/subtype?reset=1

Then click 'Add Contact Type'. Complete the 'Name' field and optionally the 'Description' field. That's it.


- and on what url you observing the weird problem.

The standard add or edit forms for contacts and cases, such as:

http://localhost/drupal-7.15/civicrm/contact/add?reset=1&context=search&action=update&cid=20

In such a situation, submitting data against custom fields in groups which extend API-created types will result in data not being saved, whereas data submitted to custom fields in groups which extend default types ('Individual') or manually (UI) created types will be correctly saved. If groups of both types are relevant to a created or edited contact, data will be saved only against fields within the groups which extend default or UI-created types.

- are you able to reproduce the problem by repeating above steps on latest install ? If not, what civicrm version you upgraded from and created most of the custom fields from apis.

Yes, I've done a clean install of 4.2.4 and the same behaviour is exhibited.

* * *

It seems to me that there must be a problem with how I have created the contact types in the API. However, here is my civicrm_contact_type table:
Code: [Select]
mysql> select * from civicrm_contact_type;
+----+---------------+---------------+---------------------------------------------------------+-----------+-----------+-----------+-------------+
| id | name          | label         | description                                             | image_URL | parent_id | is_active | is_reserved |
+----+---------------+---------------+---------------------------------------------------------+-----------+-----------+-----------+-------------+
|  1 | Individual    | Individual    | NULL                                                    | NULL      |      NULL |         1 |           1 |
|  2 | Household     | Household     | NULL                                                    | NULL      |      NULL |         1 |           1 |
|  3 | Organization  | Organisation  | NULL                                                    | NULL      |      NULL |         1 |           1 |
|  4 | Contact       | Contact       | Individuals who we might recruit into research studies. | NULL      |         1 |         1 |        NULL |
|  5 | LCBRU_Staff   | LCBRU Staff   | Staff working for the LCBRU.                            | NULL      |         1 |         1 |        NULL |
|  6 | Health_Worker | Health Worker | All health workers, whether LCBRU staff or otherwise.   | NULL      |         1 |         1 |        NULL |
|  7 | GP_Surgery    | GP Surgery    | NULL                                                    | NULL      |         3 |         1 |        NULL |
|  8 | Contact_2     | Contact 2     | testing type                                            | NULL      |         1 |         1 |        NULL |
+----+---------------+---------------+---------------------------------------------------------+-----------+-----------+-----------+-------------+

ID 4 ("Contact") is API created, data does not save against the fields in custom groups extending this contact type. ID 8 ("Contact 2") is created through the UI, and data saves correctly against fields in custom groups extending this contact type.

I can switch the settings for a single custom group to extend either of the contact types, back and forth between the two, and the behaviour continues. Extending id 4, data is not saved. Extending id 8, data is saved. Back to extending id 4, once again the data is not saved. Yet the two contact types have idential settings in this table.

Data which is submitted against the same custom fields using API calls is correctly saved, as is data submitted using the AJAX 'add or edit' mini-forms. Only when a full inline create or edit form is submitted is data ignored. Sadly, of course, this is the primary creation UI for new contacts.

Would it be helfpul to switch the display method to 'tab' for an affected custom group?

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Custom fields exhibit strange behaviour
October 22, 2012, 04:13:58 am
Nick,

Subtype 'Contact' is kinda reserved keyword for CiviCRM, and that seems to be causing the problem.

I think if you create this type even from UI, will have the same problem. So whether you use api or UI to create 'Contact' type could cause problems (my guess).

"Contact_2" (created from UI in your case) is working for your case because its different from "Contact"(created from api in your case).

If you could confirm that this exactly is the problem for you, a short term solution for you would be to update "Contact_2" label from UI to "Contact", which internally in DB will keep the name column as "Contact_2", and "Contact" would still work for you.
And delete existing 'Contact' as a type.
« Last Edit: October 22, 2012, 04:17:21 am by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Custom fields exhibit strange behaviour
October 22, 2012, 04:50:45 am
Thanks, Deepak. It's a new site install, so it's not the end of the world for us to change the name of the sub-type and use something else, so I will try that in a fresh install and let you know shortly.

nickholden

  • I post occasionally
  • **
  • Posts: 111
  • Karma: 1
  • CiviCRM version: 4.4.1
  • CMS version: Drupal 7
  • MySQL version: 5.5.32
  • PHP version: 5.4
Re: Custom fields exhibit strange behaviour
October 22, 2012, 07:55:56 am
Yes, that seems to have nailed it. It does seem that naming a subtype 'Contact' broke the system in a very limited but very significant way. In the interests of making civicrm properly idiot-proof it might be worth having an extra validation step in the subtype creation routine that ensures users cannot do this? Or are we a very special kind of idiot?

Deepak Srivastava

  • Moderator
  • Ask me questions
  • *****
  • Posts: 677
  • Karma: 65
Re: Custom fields exhibit strange behaviour
October 22, 2012, 09:01:37 am
Thanks for verifying. Filed an issue here - http://issues.civicrm.org/jira/browse/CRM-11118.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

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: Custom fields exhibit strange behaviour
October 22, 2012, 09:02:04 am
nick:

can you work on a patch for that issue to ensure that a contact sub-type cannot be named one of the current contact sub-types and the implicit Contact type

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

knob

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 4.2.0
  • CMS version: Drupal
  • MySQL version: 5.1.65-cll
  • PHP version: 5.3.16
Re: Custom fields exhibit strange behaviour
May 29, 2013, 02:01:10 am
Hello there,
I'm having the same issue with regards to saving data in custom fields. If I save in the general edit screen, It sometimes saves them, sometimes not, behaves very strangely (I am talking about one of the two advanced multiple select list fields). The other one in the same group works normally.

Very strange, and I do not even have any name conflicts - no Contact sub-type.

Any ideas?

Thanks!

Danny

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Custom fields exhibit strange behaviour

This forum was archived on 2017-11-26.